Re: [PATCH v2 xserver] os,dix: rename *.O to *.a

2017-02-13 Thread Alan Coopersmith

On 02/11/17 09:31 PM, Alan Coopersmith wrote:

Sorry, this patch breaks the generation of the dtrace objects
on Solaris, and results in the Xorg binary failing to link with:


BTW, I should mention that this was an incorrect assumption:


On 02/ 9/17 09:47 PM, Mihail Konev wrote:

Libtool was moving the *.O libraries in front of all others on
the gcc command line, which was necessiating "ld -r"
(so that symbols from now-moved os.O are visible from the following
libs), which, in turn, was altering the linker behaviour against os/
and dix/ between with-/usr/bin/dtrace and --with-dtrace=no builds.


ld -r was used not because of libtool, but because the dtrace data in the
ELF files gets properly included in a relocatable object, but not a static
library.  (This is probably because of a misuse of ELF by dtrace, but that's
the way it works, and has for over a decade.)

--
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH v2 xserver] os,dix: rename *.O to *.a

2017-02-11 Thread Alan Coopersmith

Sorry, this patch breaks the generation of the dtrace objects
on Solaris, and results in the Xorg binary failing to link with:

  CCLD Xorg
Undefined   first referenced
 symbol in file
__dtraceenabled_Xserver___request__start ../../dix/.libs/libdix.a(dispatch.o)
__dtrace_Xserver___client__disconnect ../../dix/.libs/libdix.a(dispatch.o)
__dtraceenabled_Xserver___send__event ../../dix/.libs/libdix.a(events.o)
__dtraceenabled_Xserver___request__done ../../dix/.libs/libdix.a(dispatch.o)
__dtrace_Xserver___input__event ../../dix/.libs/libdix.a(getevents.o)
__dtrace_Xserver___resource(float, long double,...)(...) 
../../dix/.libs/libdix.a(resource.o)

__dtrace_Xserver___resource__alloc  ../../dix/.libs/libdix.a(resource.o)
__dtrace_Xserver___request__start   ../../dix/.libs/libdix.a(dispatch.o)
__dtrace_Xserver___request__done../../dix/.libs/libdix.a(dispatch.o)
__dtraceenabled_Xserver___input__event ../../dix/.libs/libdix.a(getevents.o)
__dtrace_Xserver___send__event  ../../dix/.libs/libdix.a(events.o)
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status

-alan-

On 02/ 9/17 09:47 PM, Mihail Konev wrote:

Libtool was moving the *.O libraries in front of all others on
the gcc command line, which was necessiating "ld -r"
(so that symbols from now-moved os.O are visible from the following
libs), which, in turn, was altering the linker behaviour against os/
and dix/ between with-/usr/bin/dtrace and --with-dtrace=no builds.

In particular, commit 3f8c2f94483bf0b96e129c97ef4950170a3f05b4
was necessary for without-dtrace, but not for with-dtrace build.
The 3ef16dfb9830bd6b41ae428f4f213ae0c35c1056 fixed the with-dtrace,
but broke the without-dtrace build (so this commit reverts it).

Also remove dtrace lib from dix/, as only the os/ one was used.

Fixes: 49a26681 ("Add DTrace probe points")
Fixes: 3ef16dfb ("dmx: fix linking")
Reported-by: Byeong-ryeol Kim 
Signed-off-by: Mihail Konev 
---
v2:
- remove dtrace lib
- fix the with-dtrace build for tests, as done in dtrace-in-separate-dir patch.
  But this still probably does not work for --disable-xorg.
  Yet the fix shouldn't be attempted right now, as this patch conflicts with 
the pending
   https://patchwork.freedesktop.org/patch/136119/
  which is required to test the "--disable-xorg"-with-dtrace.

The dtrace-in-a-separate-dir is preferrable, IMO:
- allows for another dtrace-like additional-objects-compiler
- cleaner makefile
- simpler diff
(But note it is still not "--disable-xorg"-ready).

 configure.ac   |  6 +++---
 dix/Makefile.am| 12 
 hw/dmx/Makefile.am |  3 +--
 os/Makefile.am | 10 +-
 test/Makefile.am   |  7 ++-
 5 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4dcf8b5c27a0..3b56c9daa962 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,7 @@ dnl version-config.h covers the version numbers so they can 
be bumped without
 dnl forcing an entire recompile.x
 AC_CONFIG_HEADERS(include/version-config.h)

+AM_PROG_AR
 AM_PROG_AS
 AC_PROG_LN_S
 LT_PREREQ([2.2])
@@ -1579,11 +1580,10 @@ AC_DEFINE(XSYNC, 1, [Support XSync extension])
 AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
 AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])

+DIX_LIB='$(top_builddir)/dix/libdix.la'
 if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
-  DIX_LIB='$(top_builddir)/dix/dix.O'
-  OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS) 
$(LIBUNWIND_LIBS)'
+  OS_LIB='$(top_builddir)/os/libos_dtraced.a $(SHA1_LIBS) $(DLOPEN_LIBS) 
$(LIBUNWIND_LIBS)'
 else
-  DIX_LIB='$(top_builddir)/dix/libdix.la'
   OS_LIB='$(top_builddir)/os/libos.la'
 fi
 AC_SUBST([DIX_LIB])
diff --git a/dix/Makefile.am b/dix/Makefile.am
index a4171d7e1f12..476bd35bd566 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -59,16 +59,4 @@ Xserver-dtrace.h: $(srcdir)/Xserver.d

 endif

-if SPECIAL_DTRACE_OBJECTS
-# Generate dtrace object code for probes in libdix
-dtrace-dix.o: $(top_srcdir)/dix/Xserver.d libdix.la
-   $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d 
$(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
-
-noinst_PROGRAMS = dix.O
-
-dix_O_SOURCES =
-dix.O: dtrace-dix.o libdix.la
-   $(AM_V_GEN)ld -r -o $@ $(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
-endif
-
 CLEANFILES = Xserver-dtrace.h
diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index 38d6ac409e76..eef84cb66a76 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -80,8 +80,7 @@ XDMX_LIBS = \

 Xdmx_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 Xdmx_DEPENDENCIES= $(XDMX_LIBS)
-Xdmx_LDADD = $(XDMX_LIBS) $(XDMX_SYS_LIBS) $(XSERVER_SYS_LIBS) \
- $(top_builddir)/render/librender.la
+Xdmx_LDADD = $(XDMX_LIBS) $(XDMX_SYS_LIBS) $(XSERVER_SYS_LIBS)

 relink:
$(AM_V_at)rm -f Xdmx$(EXEEXT) && $(MAKE) Xdmx$(EXEEXT)
diff --git a/os/Makefile.am b/os/Makefile.am
index c6e78cb99fd5..b43113ea5d98 

Re: [PATCH v2 xserver] os,dix: rename *.O to *.a

2017-02-10 Thread Mihail Konev
Changing the To: field unintendedly changed recipients, so resending
this as a notification, even through it becomes quite a flood.

On Sat, Feb 11, 2017 at 04:15:19AM +0500, Mihail Konev wrote:
> Log of searching for "ld -r" attached, in case it is of any help.
> 
> On Fri, Feb 10, 2017 at 10:47:29AM +0500, Mihail Konev wrote:
> > 
> > The dtrace-in-a-separate-dir is preferrable, IMO:
> > - allows for another dtrace-like additional-objects-compiler
> > - cleaner makefile
> > - simpler diff
> > 
> 
> Really no difference.
> While it would be indeed more straightforward to not have
> libos_dtraced.la, this could be as well archieved with
> 
>   libos_la_LIBADD=
>   if SPECIAL_DTRACE_OBJECTS
> libos_la_LIBADD += dtrace.a
>   endif
>   if ANOTHER_OBJECTS
> libos_la_LIBADD += another.a
>   fi
> 
> So it is just of preference, whether to use some misc/ top-level
> subdir for dtrace or just leave it in-line as it is now.
> 
> Mihail

Mihail
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH v2 xserver] os,dix: rename *.O to *.a

2017-02-10 Thread Mihail Konev
Log of searching for "ld -r" attached, in case it is of any help.

On Fri, Feb 10, 2017 at 10:47:29AM +0500, Mihail Konev wrote:
> 
> The dtrace-in-a-separate-dir is preferrable, IMO:
> - allows for another dtrace-like additional-objects-compiler
> - cleaner makefile
> - simpler diff
> 

Really no difference.
While it would be indeed more straightforward to not have
libos_dtraced.la, this could be as well archieved with

  libos_la_LIBADD=
  if SPECIAL_DTRACE_OBJECTS
libos_la_LIBADD += dtrace.a
  endif
  if ANOTHER_OBJECTS
libos_la_LIBADD += another.a
  fi

So it is just of preference, whether to use some misc/ top-level
subdir for dtrace or just leave it in-line as it is now.

Mihail
Built 058809c43ec578a407cf40d4c3e54a42503e3562 as:
  ./configure --enable-dmx,
  with /usr/bin/dtrace being present (from the systemtap)

It suceeds.

Saved the output of:
  rm hw/dmx/Xdmx
  make -C hw/dmx Xdmx V=1 CFLAGS='-v'

Then built the same as:
  ./configure --enable-dmx --with-dtrace=no

It fails, as on a fresh Ubuntu 17.04, where systemtap
is not installed by default (HashGlyph cannot find x_sha1_init,
e.g. librender.a cannot find libos.a).

Noticed that in the /usr/bin/dtrace case, the librender does find
the os.O's x_sha1_init, even through the latter is put, by libtool,
in front of all other libraries (e.g. right after the dmx*.o files).

Ran the:
  rm os/.libs/libos.a
  make -C os libos.la V=1 CFLAGS='-v'

It shows that libos.a is created with 'ar cru', i.e. there is no linker 
involved.
(There also is 'ranlib', but it is just another form of 'ar' invocation).

Noticed that os.O is built with 'ld':
  ld -r -o $@ dtrace.o .libs/*.o

So there is the linker involved, and it is passed a '--relocatable' flag,
which puts it into under-documented "partial linking" mode.
(Neither 'info ld' nor google describe it).

Then took the collect2 invocation command from the output of the 'make Xdmx' for
successfull /usr/bin/dtrace case, and edited as:
  ../../os/os.O   -> ../../os.O1
  ../../dix/dix.O -> ../../dix.O1

Then created the O1 files:
  ld -r -o os.O1 os/.libs/*.o
  ld -r -o dix.O1 dix/.libs/*.o

Then ran the edited collect2 command line and it worked.

So the "ld -r" must be making symbols visible from an object 
for-the-following-libraries
on the linker command line, not only for-the-preceding-ones, as it is with
"ar cru"-ed foo.a and non-"ld -r"-ed -lbar.

Now, the "-r" was not explained, but could be assumed to be a workaround
for libtool's putting-os.O-in-front-of-all-else
("git log -L 68,68:os/Makefile.am"):

  commit 49a26681b2bdd95ed65c425f1fa1441d2f092a6e
  Author: Alan Coopersmith 
  Date:   Fri Nov 3 12:54:43 2006 -0800

  Add DTrace probe points for X server <-> client communications

  See http://people.freedesktop.org/~alanc/dtrace/ for more details

  diff --git a/os/Makefile.am b/os/Makefile.am
  --- a/os/Makefile.am
  +++ b/os/Makefile.am
  @@ -53,0 +62,1 @@
  +   ld -r -o $@ dtrace.o .libs/*.o

There are two solutions - either use os.O regardless of the dtrace presence and 
do

ld -r -o $@ $(DTRACE_O_OR_NOTHING) .libs/*.o

or do not use "ld -r" at all and "ar cru" the .libs/libdix.a manually.

The latter seems to be less depending on ld capabilities, and thus, more 
portable.

Implementing it, however, reveals that the commit actually leaved dix.O intact, 
instead
putting both dix/dtrace.o and os/dtrace.o into the os.O.
This is required, as otherwise:

  diff --git a/dix/Makefile.am b/dix/Makefile.am
  index a4171d7e1f12..1094f331a722 100644
  --- a/dix/Makefile.am
  +++ b/dix/Makefile.am
  @@ -61,14 +61,14 @@ endif
   if SPECIAL_DTRACE_OBJECTS
   # Generate dtrace object code for probes in libdix
  -dtrace-dix.o: $(top_srcdir)/dix/Xserver.d libdix.la
  +dix-dtrace.o: $(top_srcdir)/dix/Xserver.d libdix.la
  $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d 
$(am_libdix_la_OBJECTS:%.lo=.libs/%.o)

   noinst_PROGRAMS = dix.O

   dix_O_SOURCES =
  -dix.O: dtrace-dix.o libdix.la
  -   $(AM_V_GEN)ld -r -o $@ $(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
  +dix.O: dix-dtrace.o libdix.la
  +   $(AM_V_GEN)ld -r -o $@ $< $(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
   endif

   CLEANFILES = Xserver-dtrace.h
  diff --git a/os/Makefile.am b/os/Makefile.am
  index c6e78cb99fd5..b61a331990a5 100644
  --- a/os/Makefile.am
  +++ b/os/Makefile.am
  @@ -58,12 +58,12 @@ EXTRA_DIST = $(SECURERPC_SRCS) $(XDMCP_SRCS)

   if SPECIAL_DTRACE_OBJECTS
   # Generate dtrace object code for probes in libos & libdix
  -dtrace.o: $(top_srcdir)/dix/Xserver.d libos.la
  -   $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d 
.libs/*.o ../dix/.libs/*.o
  +os-dtrace.o: $(top_srcdir)/dix/Xserver.d libos.la
  +   $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d 
.libs/*.o

   noinst_PROGRAMS = os.O

   os_O_SOURCES =
  -os.O: dtrace.o libos.la
  -   $(AM_V_GEN)ld -r -o $@ dtrace.o .libs/*.o
  +os.O: os-dtrace.o libos.la
  +  

[PATCH v2 xserver] os,dix: rename *.O to *.a

2017-02-09 Thread Mihail Konev
Libtool was moving the *.O libraries in front of all others on
the gcc command line, which was necessiating "ld -r"
(so that symbols from now-moved os.O are visible from the following
libs), which, in turn, was altering the linker behaviour against os/
and dix/ between with-/usr/bin/dtrace and --with-dtrace=no builds.

In particular, commit 3f8c2f94483bf0b96e129c97ef4950170a3f05b4
was necessary for without-dtrace, but not for with-dtrace build.
The 3ef16dfb9830bd6b41ae428f4f213ae0c35c1056 fixed the with-dtrace,
but broke the without-dtrace build (so this commit reverts it).

Also remove dtrace lib from dix/, as only the os/ one was used.

Fixes: 49a26681 ("Add DTrace probe points")
Fixes: 3ef16dfb ("dmx: fix linking")
Reported-by: Byeong-ryeol Kim 
Signed-off-by: Mihail Konev 
---
v2:
- remove dtrace lib
- fix the with-dtrace build for tests, as done in dtrace-in-separate-dir patch.
  But this still probably does not work for --disable-xorg.
  Yet the fix shouldn't be attempted right now, as this patch conflicts with 
the pending
   https://patchwork.freedesktop.org/patch/136119/
  which is required to test the "--disable-xorg"-with-dtrace.

The dtrace-in-a-separate-dir is preferrable, IMO:
- allows for another dtrace-like additional-objects-compiler
- cleaner makefile
- simpler diff
(But note it is still not "--disable-xorg"-ready).

 configure.ac   |  6 +++---
 dix/Makefile.am| 12 
 hw/dmx/Makefile.am |  3 +--
 os/Makefile.am | 10 +-
 test/Makefile.am   |  7 ++-
 5 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4dcf8b5c27a0..3b56c9daa962 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,6 +73,7 @@ dnl version-config.h covers the version numbers so they can 
be bumped without
 dnl forcing an entire recompile.x
 AC_CONFIG_HEADERS(include/version-config.h)
 
+AM_PROG_AR
 AM_PROG_AS
 AC_PROG_LN_S
 LT_PREREQ([2.2])
@@ -1579,11 +1580,10 @@ AC_DEFINE(XSYNC, 1, [Support XSync extension])
 AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
 AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])
 
+DIX_LIB='$(top_builddir)/dix/libdix.la'
 if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
-  DIX_LIB='$(top_builddir)/dix/dix.O'
-  OS_LIB='$(top_builddir)/os/os.O $(SHA1_LIBS) $(DLOPEN_LIBS) 
$(LIBUNWIND_LIBS)'
+  OS_LIB='$(top_builddir)/os/libos_dtraced.a $(SHA1_LIBS) $(DLOPEN_LIBS) 
$(LIBUNWIND_LIBS)'
 else
-  DIX_LIB='$(top_builddir)/dix/libdix.la'
   OS_LIB='$(top_builddir)/os/libos.la'
 fi
 AC_SUBST([DIX_LIB])
diff --git a/dix/Makefile.am b/dix/Makefile.am
index a4171d7e1f12..476bd35bd566 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -59,16 +59,4 @@ Xserver-dtrace.h: $(srcdir)/Xserver.d
 
 endif
 
-if SPECIAL_DTRACE_OBJECTS
-# Generate dtrace object code for probes in libdix
-dtrace-dix.o: $(top_srcdir)/dix/Xserver.d libdix.la
-   $(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d 
$(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
-
-noinst_PROGRAMS = dix.O
-
-dix_O_SOURCES =
-dix.O: dtrace-dix.o libdix.la
-   $(AM_V_GEN)ld -r -o $@ $(am_libdix_la_OBJECTS:%.lo=.libs/%.o)
-endif
-
 CLEANFILES = Xserver-dtrace.h
diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index 38d6ac409e76..eef84cb66a76 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -80,8 +80,7 @@ XDMX_LIBS = \
 
 Xdmx_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
 Xdmx_DEPENDENCIES= $(XDMX_LIBS)
-Xdmx_LDADD = $(XDMX_LIBS) $(XDMX_SYS_LIBS) $(XSERVER_SYS_LIBS) \
- $(top_builddir)/render/librender.la
+Xdmx_LDADD = $(XDMX_LIBS) $(XDMX_SYS_LIBS) $(XSERVER_SYS_LIBS)
 
 relink:
$(AM_V_at)rm -f Xdmx$(EXEEXT) && $(MAKE) Xdmx$(EXEEXT)
diff --git a/os/Makefile.am b/os/Makefile.am
index c6e78cb99fd5..b43113ea5d98 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -58,12 +58,12 @@ EXTRA_DIST = $(SECURERPC_SRCS) $(XDMCP_SRCS)
 
 if SPECIAL_DTRACE_OBJECTS
 # Generate dtrace object code for probes in libos & libdix
-dtrace.o: $(top_srcdir)/dix/Xserver.d libos.la
+dtrace.o: $(top_srcdir)/dix/Xserver.d libos.la ../dix/libdix.la
$(AM_V_GEN)$(DTRACE) -G -C -o $@ -s $(top_srcdir)/dix/Xserver.d 
.libs/*.o ../dix/.libs/*.o
 
-noinst_PROGRAMS = os.O
+noinst_PROGRAMS = libos_dtraced.a
 
-os_O_SOURCES =
-os.O: dtrace.o libos.la
-   $(AM_V_GEN)ld -r -o $@ dtrace.o .libs/*.o
+libos_dtraced_a_SOURCES =
+libos_dtraced.a: dtrace.o libos.la
+   $(AM_V_GEN) $(AR) cru $@ dtrace.o .libs/*.o
 endif
diff --git a/test/Makefile.am b/test/Makefile.am
index e7fe587bb858..fb61d614bf10 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -140,11 +140,8 @@ tests_LDADD += \
 $(top_builddir)/hw/xfree86/i2c/libi2c.la \
 $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la \
 $(top_builddir)/Xext/libXvidmode.la \
-@XORG_LIBS@
-
-if !SPECIAL_DTRACE_OBJECTS
-tests_LDADD += $(top_builddir)/os/libos.la
-endif
+$(XORG_LIBS) \
+$(top_builddir)/os/libos.la