[CMake] Suppressing -rdynamic in toolchain file

2014-04-04 Thread Gerhard Gappmeier
Hi

I'm trying to use -ffunction-sections -fdata-sections as C_FLAGS and -Wl,--gc-
sections when cross-compiling for my ARM Linux target.

The gc-sections option does not work because CMake adds the -rdynamic flag 
which exports all symbols, also the unused ones.

I already figured out that I can suppress this be setting 
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )

This work is the CMakeLists.txt files, but it does not work from a toolchain 
file.
But I want to configure this in my toolchain file, because this setting is 
specific for this single target. It is not an option add this as generic 
setting for all targets.

I also tried this:
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS  CACHE INTERNAL   FORCE)

But this does not work either.

I believe this is a problem of the order how CMake files are processed. It 
looks like the toolchain file is processed first and then 
/usr/share/cmake/Modules/Platform/Linux-GNU.cmake
which overwrites the toolchain settings (just a guess)

BTW: I had similar problems with settings CMAKE_C_FLAGS, etc. from the 
toochain file.

# this does not work
SET(CMAKE_C_FLAGS -Wall -Wextra -std=gnu99 -fdata-sections -ffunction-
sections)

# with CACHE FORCE it does work
SET(CMAKE_C_FLAGS -Wall -Wextra -std=gnu99 -fdata-sections -ffunction-
sections CACHE INTERNAL c compiler flags FORCE)

I'm not sure if this was intended. And for CMAKE_SHARED_LIBRARY_LINK_C_FLAGS 
this does not work either, as explained above.

I hope somebody can clarify how this options can be configured properly the 
CMake way.

PS: I'm using cmake version 2.8.12.2

-- 
mit freundlichen Grüßen / best regards

Gerhard Gappmeier
ascolab GmbH - automation systems communication laboratory
Tel.: +49 9131 691 123
Fax: +49 9131 691 128
Web: http://www.ascolab.com
GPG-KeyId: 5AAC50C4
GPG-Fingerprint: 967A 15F1 2788 164D CCA3 6C46 07CD 6F82 5AAC 50C4

--
ascolab GmbH
Geschäftsführer: Gerhard Gappmeier, Matthias Damm, Uwe Steinkrauß
Sitz der Gesellschaft: Am Weichselgarten 7 • 91058 Erlangen • Germany
Registernummer: HRB 9360
Registergericht: Amtsgericht Fürth

signature.asc
Description: This is a digitally signed message part.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Suppressing -rdynamic

2007-10-06 Thread Gonzalo Garramuño
I'm compiling under Linux and it seems like cmake is automatically 
adding -rdynamic to my build.
This switch is okay for debug builds and open source tools, but for 
closed source it is a big problem.
This switch is unfortunately exposing some unwanted functions in my 
code, like the licensing functions.
This makes the functions easily available by using objdump -T or nm -D, 
even if the executable has been stripped.


Is there a way to suppress the use of this switch?

--
Gonzalo Garramuño
[EMAIL PROTECTED]

AMD4400 - ASUS48N-E
GeForce7300GT
Kubuntu Edgy

___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Suppressing -rdynamic

2007-10-06 Thread Filip Brcic
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Дана субота 06 октобар 2007, Gonzalo Garramuño је написао(ла):
 I'm compiling under Linux and it seems like cmake is automatically
 adding -rdynamic to my build.
 This switch is okay for debug builds and open source tools, but for
 closed source it is a big problem.
 This switch is unfortunately exposing some unwanted functions in my
 code, like the licensing functions.
 This makes the functions easily available by using objdump -T or nm -D,
 even if the executable has been stripped.

 Is there a way to suppress the use of this switch?

Hi,

If you do a:

[EMAIL PROTECTED] ~]$ cd /usr/share/cmake/Modules
[EMAIL PROTECTED] Modules]$ grep 'rdynamic' *
[EMAIL PROTECTED] Modules]$ grep 'rdynamic' */*
Platform/kFreeBSD.cmake:SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS -rdynamic)
Platform/Linux.cmake:SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS -rdynamic)

Therefore, you have to override CMAKE_SHARED_LIBRARY_LINK_C_FLAGS and set it 
to blank. Something like:

SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )

or something like that.

And do consider making your program free software ;)

Best regards
Filip

- -- 
Filip Brcic [EMAIL PROTECTED]
WWWeb: http://purl.org/NET/brcha/home/
Jabber: [EMAIL PROTECTED]
ICQ# 40994923
Yahoo! brcha
MSN: [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHB3yReugpoxYs6H8RAki+AKCtU8j2w5QDp5pLOvQwNhyCvfNTowCgnr4R
HWboVDawlQ/yqDMTGatbtro=
=kC2K
-END PGP SIGNATURE-
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Suppressing -rdynamic

2007-10-06 Thread Gonzalo Garramuño


Therefore, you have to override CMAKE_SHARED_LIBRARY_LINK_C_FLAGS and set it 
to blank. Something like:


SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )

or something like that.



Did you actually try it?  Suppressing the variable does nothing.
Even replacing Linux.cmake with my own does nothing.


--
Gonzalo Garramuño
[EMAIL PROTECTED]

AMD4400 - ASUS48N-E
GeForce7300GT
Kubuntu Edgy
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Suppressing -rdynamic

2007-10-06 Thread Filip Brcic
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Дана субота 06 октобар 2007, Gonzalo Garramuño је написао(ла):
  Therefore, you have to override CMAKE_SHARED_LIBRARY_LINK_C_FLAGS and set
  it to blank. Something like:
 
  SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )
 
  or something like that.

 Did you actually try it?  Suppressing the variable does nothing.
 Even replacing Linux.cmake with my own does nothing.

It works for me. Take a look at the attacked program.

Here is my version of CMake:
[EMAIL PROTECTED] ~]$ rpm -q cmake
cmake-2.4.6-4.fc7

and here is the output of the verbose build:
[EMAIL PROTECTED] build]$ make VERBOSE=1
/usr/bin/cmake -H/Users/brcha/tmp/helloWorld 
-B/Users/brcha/tmp/helloWorld/build --check-build-system 
CMakeFiles/Makefile.cmake 0
Clearing dependencies in CMakeFiles/helloWorld.dir/depend.make.
Clearing dependencies in CMakeFiles/helloWorld.dir/depend.internal.
/usr/bin/cmake -E 
cmake_progress_start /Users/brcha/tmp/helloWorld/build/CMakeFiles 1
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/Users/brcha/tmp/helloWorld/build'
make -f CMakeFiles/helloWorld.dir/build.make CMakeFiles/helloWorld.dir/depend
make[2]: Entering directory `/Users/brcha/tmp/helloWorld/build'
Scanning dependencies of target helloWorld
cd /Users/brcha/tmp/helloWorld/build  /usr/bin/cmake -E cmake_depends Unix 
Makefiles /Users/brcha/tmp/helloWorld /Users/brcha/tmp/helloWorld 
/Users/brcha/tmp/helloWorld/build /Users/brcha/tmp/helloWorld/build 
/Users/brcha/tmp/helloWorld/build/CMakeFiles/helloWorld.dir/DependInfo.cmake
make[2]: Leaving directory `/Users/brcha/tmp/helloWorld/build'
make -f CMakeFiles/helloWorld.dir/build.make CMakeFiles/helloWorld.dir/build
make[2]: Entering directory `/Users/brcha/tmp/helloWorld/build'
/usr/bin/cmake -E 
cmake_progress_report /Users/brcha/tmp/helloWorld/build/CMakeFiles 1
[100%] Building C object CMakeFiles/helloWorld.dir/helloWorld.o
/usr/lib64/ccache/gcc   -o 
CMakeFiles/helloWorld.dir/helloWorld.o   -c 
/Users/brcha/tmp/helloWorld/helloWorld.c
Linking C executable helloWorld
/usr/bin/cmake -P CMakeFiles/helloWorld.dir/cmake_clean_target.cmake
/usr/lib64/ccache/gcc -fPIC CMakeFiles/helloWorld.dir/helloWorld.o   -o 
helloWorld
make[2]: Leaving directory `/Users/brcha/tmp/helloWorld/build'
/usr/bin/cmake -E 
cmake_progress_report /Users/brcha/tmp/helloWorld/build/CMakeFiles  1
[100%] Built target helloWorld
make[1]: Leaving directory `/Users/brcha/tmp/helloWorld/build'
/usr/bin/cmake -E 
cmake_progress_start /Users/brcha/tmp/helloWorld/build/CMakeFiles 0


- -- 
Filip Brcic [EMAIL PROTECTED]
WWWeb: http://purl.org/NET/brcha/home/
Jabber: [EMAIL PROTECTED]
ICQ# 40994923
Yahoo! brcha
MSN: [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHB6JHeugpoxYs6H8RAmmfAJ9txffofxr6P2JDZo0BAgdVKZu6oQCgkMKo
tFUi7uJt6A/qTPh/AaY5NQY=
=qIJ2
-END PGP SIGNATURE-


helloWorld.tar.bz2
Description: application/tbz
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Suppressing -rdynamic

2007-10-06 Thread Gonzalo Garramuño

Filip Brcic wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Дана субота 06 октобар 2007, Gonzalo Garramuño је написао(ла):

Therefore, you have to override CMAKE_SHARED_LIBRARY_LINK_C_FLAGS and set
it to blank. Something like:

SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )



CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS seems to be the key for c++.  Have 
not been able to guess where that is set thou.


--
Gonzalo Garramuño
[EMAIL PROTECTED]

AMD4400 - ASUS48N-E
GeForce7300GT
Kubuntu Edgy
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Suppressing -rdynamic

2007-10-06 Thread Filip Brcic
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Дана субота 06 октобар 2007, Gonzalo Garramuño је написао(ла):
 Filip Brcic wrote:
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  Дана субота 06 октобар 2007, Gonzalo Garramuño је написао(ла):
  Therefore, you have to override CMAKE_SHARED_LIBRARY_LINK_C_FLAGS and
  set it to blank. Something like:
 
  SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS )

 CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS seems to be the key for c++.  Have
 not been able to guess where that is set thou.

Yes, you are right. I made a new advanced version of my helloWorld++ (tm) 
program using C++ (and cout for output) and it did include -rdynamic when 
linking. But, after I added set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS ) the 
problem dissapeared. Nice catch :)

And, here is where that is comming from:

[EMAIL PROTECTED] Modules]$ grep CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS *
CMakeCXXInformation.cmake:IF(NOT CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
CMakeCXXInformation.cmake:  SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS 
${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
CMakeCXXInformation.cmake:ENDIF(NOT CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)

Since that is evaluated in enable_language(CXX) (I guess), it uses the system 
CMAKE_SHARED_LIBRARY_LINK_C_FLAGS variable and not the CMakeFiles.txt 
version. For Fortran you should override 
CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS in the same way.

- -- 
Filip Brcic [EMAIL PROTECTED]
WWWeb: http://purl.org/NET/brcha/home/
Jabber: [EMAIL PROTECTED]
ICQ# 40994923
Yahoo! brcha
MSN: [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHB68yeugpoxYs6H8RAiRSAJ494iWTcacqdf3ocJV+GqsH52appgCeJ679
VA9XwuAU4M/vi+OpIP9DdyY=
=raJ3
-END PGP SIGNATURE-
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake