[Cmake] getting rid of -nostdlib in Solaris

Wheeler, Frederick W (Research) wheeler at crd.ge.com
Wed Mar 12 16:44:58 EST 2003


CMake List:

Right to the point: I could use a way to get rid of the -nostdlib option to
gcc in Solaris without having to edit SunOS.cmake.  Thanks.

The whole story:

A year ago I figured out that I had to get rid of the -nostdlib option to
get VXL execs to run when building using shared libs in Solaris.  There was
a big debate on this list over the right way to make shared libs with gcc.
For me, the bottom line is that the programs segfault when I use -nostdlib
and run fine when I omit it.

Here is a link to some advice from Jason Merrill, who should know,
http://sources.redhat.com/ml/bug-binutils/2002-q1/msg00052.html

For the past year I've been using the following cache entries to get rid of
-nostdlib.

CMAKE_MODULE_BUILD_FLAGS:STRING=-shared
CMAKE_SHLIB_BUILD_FLAGS:STRING=-shared

I see things have changed.  The -nostdlib option has snuck back in, causing
many of my VXL/Solaris/Shared tests to fail.  These seem to be the new
relevant cache entries,

CMAKE_EXE_LINKER_FLAGS:STRING=
CMAKE_MODULE_LINKER_FLAGS:STRING=
CMAKE_SHARED_LINKER_FLAGS:STRING=

However, option -nostdlib is still used no matter what the above entries are
set to.  I see that it is added in SunOS.cmake.  I tried this in the cache,

CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS:STRING=-shared
CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS:STRING=-shared

But, of course, this will not work since these are ordinary variables, not
in the cache.

So, can a means to remove the -nostdlib option be added to the way
configuration is done in SunOS.cmake?

I build part of VXL with the following commands.  vsl_test_all segfaulted.
The, I removed "-nostdlib" from SunOS.cmake and repeated.  vsl_test_all ran
perfectly.  I'm sure this will fix all of the other segfaulting tests.

# remove and configure
cd $SRW
rm -rf $SRW/sol_bld
mkdir -p $SRW/sol_bld
cd $SRW/sol_bld
cat > CMakeCache.txt <<EOF
CMAKE_VERBOSE_MAKEFILE:BOOL=ON
CMAKE_C_FLAGS:STRING=-Wall -g
CMAKE_CXX_FLAGS:STRING=-Wall -g
BUILD_SHARED_LIBS:BOOL=ON
VXL_FORCE_V3P_ZLIB:BOOL=YES
VXL_FORCE_V3P_PNG:BOOL=YES
VXL_FORCE_V3P_JPEG:BOOL=YES
VXL_FORCE_V3P_MPEG2:BOOL=YES
VXL_FORCE_V3P_TIFF:BOOL=YES
EOF
cmake $SRW/vxl_src
# build vsl tests
cd $SRW/sol_bld/core/vsl/tests
time make
./vsl_test_all
# seg fault core dump unless I remove -nostdlib


Here is some information on the system,


0% uname -a
SunOS caleb 5.8 Generic_108528-17 sun4u sparc
0% gcc --version
3.0.4
0% ld --version
GNU ld 2.11.2
Copyright 2001 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.
  Supported emulations:
   elf32_sparc
   elf64_sparc

I'm using cmake 1.6.0, compiled from the source.

Thanks,
Fred Wheeler



More information about the CMake mailing list