* Re: Build CVS insight on x86_64
2009-01-14 11:00 Build CVS insight on x86_64 Jie Zhang
@ 2009-02-26 22:10 ` Kevin Buettner
2009-02-28 7:22 ` Keith Seitz
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Buettner @ 2009-02-26 22:10 UTC (permalink / raw)
To: insight
On Wed, 14 Jan 2009 18:57:16 +0800
Jie Zhang <jie.zhang@analog.com> wrote:
> Does anyone succeed in building CVS insight on x86_64? I tried a native
> build today on Debian unstable AMD64. But it failed. The error is:
>
> gcc -pipe -shared -o libitk3.3.so itk_cmds.o itk_option.o
> itk_archetype.o itk_util.o itkStubInit.o -lX11
> -L/home/jie/sources/insight/build/tcl/unix -ltclstub8.4
> -L/home/jie/sources/insight/build/tk/unix -ltkstub8.4
> -L/home/jie/sources/insight/build/itcl/itcl -litclstub3.3
> /usr/bin/ld: itk_cmds.o: relocation R_X86_64_32 against `a local symbol'
> can not be used when making a shared object; recompile with -fPIC
> itk_cmds.o: could not read symbols: Bad value
> collect2: ld returned 1 exit status
>
> But it on i386 host is OK. But the insight 6.8 release on x86_64 is also OK.
I've spent some time looking into this. At configuration time, the
itcl and itk packages compute a CFLAGS setting for the generated
Makefile. For some hosts, it's critcal that these settings be used.
If you look at resultant Makefile in itcl/{itcl,itk} (in your build
directory), you'll see lines which look like this:
CFLAGS = -g -O2 ${CFLAGS_DEFAULT} ${CFLAGS_WARNING} ${SHLIB_CFLAGS}
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
That CFLAGS line was generated from this line in Makefile.in:
CFLAGS = @CFLAGS@
SHLILB_CFLAGS has that all important -fPIC option mentioned in the
error message. The only places that it appears in the Makefile are
where it is being assigned and in that CFLAGS setting noted above,
but only as a result of a substitution. Thus, it's critically
important that the itcl- or itk-specific version of CFLAGS be used
when compiling a file.
What is happening is that the top level Makefile has its own set of CFLAGS
that it passes down to each of the sub-makes. This CFLAGS setting is
overriding the itcl- and itk-specific CFLAGS settings. That means that
those critically important itcl- and itk-specific CFLAGS definitions
are *not* being used.
The reason that it works on a 32-bit x86 host, but not on x86_64 is
because the x86 host doesn't seem to _really_ need the -fPIC option in
order to compile successfully. I've checked the x86 build without my
patch below and it does not use -fPIC, even though -fPIC is specified
for SHLIB_CFLAGS in the Makefile.
I have a patch for this problem; see below. What my patch does is
rename CFLAGS to either ITCL_CFLAGS or ITK_CFLAGS. It then uses these
new makefile variables in the definition of COMPILE. Note that CFLAGS
is still present for COMPILE. This is important so that any build
specific optimization switches (or whatever) get passed from the top
down to these packages.
Keith, is this okay to commit?
* itcl/Makefile.in (ITCL_CFLAGS): Renamed from CFLAGS.
(COMPILE): Use ITCL_CFLAGS in addition to CFLAGS.
* itk/Makefile.in (ITK_CFLAGS): Renamed from CFLAGS.
(COMPILE): Use ITK_CFLAGS in addition to CFLAGS.
Index: itcl/Makefile.in
===================================================================
RCS file: /cvs/src/src/itcl/itcl/Makefile.in,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.in
--- itcl/Makefile.in 23 Jul 2008 22:44:50 -0000 1.7
+++ itcl/Makefile.in 26 Feb 2009 21:36:47 -0000
@@ -145,8 +145,8 @@ CONFIG_CLEAN_FILES = @CONFIG_CLEAN_FILES
CPPFLAGS = @CPPFLAGS@
LIBS = @PKG_LIBS@ @LIBS@
AR = @AR@
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+ITCL_CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ITCL_CFLAGS)
#========================================================================
# Start of user-definable TARGETS section
Index: itk/Makefile.in
===================================================================
RCS file: /cvs/src/src/itcl/itk/Makefile.in,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.in
--- itk/Makefile.in 23 Jul 2008 22:44:51 -0000 1.7
+++ itk/Makefile.in 26 Feb 2009 21:36:47 -0000
@@ -170,8 +170,8 @@ CONFIG_CLEAN_FILES = @CONFIG_CLEAN_FILES
CPPFLAGS = @CPPFLAGS@
LIBS = @PKG_LIBS@ @LIBS@
AR = @AR@
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+ITK_CFLAGS = @CFLAGS@
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(ITK_CFLAGS)
#========================================================================
# Start of user-definable TARGETS section
^ permalink raw reply [flat|nested] 4+ messages in thread