Re: -fvisibility not being passed to the compiler in Xcode 3.2.4?
Re: -fvisibility not being passed to the compiler in Xcode 3.2.4?
- Subject: Re: -fvisibility not being passed to the compiler in Xcode 3.2.4?
- From: Juan Manuel Palacios <email@hidden>
- Date: Tue, 28 Sep 2010 16:37:40 -0430
On Sep 27, 2010, at 6:53 PM, Juan Manuel Palacios wrote:
>
> Good evening all! I'm new here so please excuse me if my problem has already been addressed, but I've been searching the list archives and Googling all afternoon and still can't find an answer. I'm compiling a personal project with Xcode 3.2.4 on a 10.6.4 SL system, and I'm fearing the -fvisibility flag is not being passed to the compiler. Here's a detailed description of the problem:
>
> 1) The project consists of two targets, one compiling a dynamic library and a second one creating the end-user app, dependent on the library;
> 2) the compiler is set to clang 1.5, but the problem rears its head just the same with GCC 4.2 selected;
> 3) for all build configurations, the dynamic library target, "libssfm", has the "Symbols Hidden by Default" option selected;
> 4) my library's header file has the Apple recommended #define EXPORT __attribute__((visibility("default"))) macro declared;
> 5) symbols I want exported are marked as the following example: EXPORT int ssfm_init(void);
> 6) symbols I *don't* want exported are *not* marked EXPORT, such as: void some_private_symbol(void);
> 7) the resulting library file ends up exporting the hidden symbols, which according to my understanding should *not* happen:
>
> -> nm -gm build/Debug/libssfm.0.dylib | grep private
> 0000000000000d0f (__TEXT,__text) external _some_private_symbol
A small follow up to my post, and maybe even perhaps a partial resolution of the problem...
Even though the "Symbols Hidden by Default" option is selected for both the Debug and Release build configurations for my libssfm dynamic library target, it turns out that when I build the entire project in Release mode the -fvisibility=hidden flag is indeed passed to the compiler, as shown below:
CompileC "build/NLSE Solver.build/Release/libssfm.build/Objects-normal/x86_64/ssfm.o" ssfm/ssfm.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
cd "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver"
setenv LANG en_US.US-ASCII
/Developer/usr/bin/clang -x c -arch x86_64 -fmessage-length=0 -pipe -fdiagnostics-print-source-range-info -std=gnu99 -Wno-trigraphs -fpascal-strings -Os -Wmissing-field-initializers -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-parameter -Wunused-variable -Wunused-value -pedantic -Wshadow -Wsign-compare -Wnewline-eof -Wshorten-64-to-32 -isysroot /Developer/SDKs/MacOSX10.6.sdk -fasm-blocks -mmacosx-version-min=10.5 -gdwarf-2 -msse3 -mssse3 -fvisibility=hidden -msse4.1 -msse4.2 -iquote "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Release/libssfm.build/libssfm.0-generated-files.hmap" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Release/libssfm.build/libssfm.0-own-target-headers.hmap" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Release/libssfm.build/libssfm.0-all-target-headers.hmap" -iquote "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Release/libssfm.build/libssfm.0-project-headers.hmap" "-F/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Release" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Release/include" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Release/libssfm.build/DerivedSources/x86_64" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Release/libssfm.build/DerivedSources" -c "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/ssfm/ssfm.c" -o "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Release/libssfm.build/Objects-normal/x86_64/ssfm.o"
And the resulting library does indeed hide the non-export test symbol I created:
-> nm -gm build/Release/libssfm.0.dylib | grep private
(no matches)
These results are easily reproduced by switching to GCC 4.2, but then I'm back with a missing -fvisibility flag when I switch the entire project to the Debug build configuration, regardless of the compiler used.
So, is it that, for some reason, Xcode purposefully foregoes passing -fvisibility to the compiler when the project is being built in Debug mode? If so, shouldn't there be a clearer UI indication of this (like the relevant option graying-out in the Build info pane when Debug is the active configuration)? Or is it still a bug, albeit one limited to the Debug configuration of a project?
Thanks again for any tips! Regards,
- jmpp
>
> Here are the compile lines that create my shared library (which at the moment is comprised of a single source module):
>
> CompileC "build/NLSE Solver.build/Debug/libssfm.build/Objects-normal/x86_64/ssfm.o" ssfm/ssfm.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler
> cd "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver"
> setenv LANG en_US.US-ASCII
> /Developer/usr/bin/clang -x c -arch x86_64 -fmessage-length=0 -pipe -fdiagnostics-print-source-range-info -std=gnu99 -Wno-trigraphs -fpascal-strings -O0 -Wmissing-field-initializers -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-parameter -Wunused-variable -Wunused-value -pedantic -Wshadow -Wsign-compare -Wnewline-eof -Wshorten-64-to-32 -isysroot /Developer/SDKs/MacOSX10.6.sdk -fasm-blocks -mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2 -msse3 -mssse3 -msse4.1 -msse4.2 -iquote "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-generated-files.hmap" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-own-target-headers.hmap" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-all-target-headers.hmap" -iquote "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-project-headers.hmap" "-F/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug/include" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/DerivedSources/x86_64" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/DerivedSources" -c "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/ssfm/ssfm.c" -o "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/Objects-normal/x86_64/ssfm.o"
>
> Ld build/Debug/libssfm.0.dylib normal x86_64
> cd "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver"
> setenv MACOSX_DEPLOYMENT_TARGET 10.5
> /Developer/usr/bin/clang -arch x86_64 -dynamiclib -isysroot /Developer/SDKs/MacOSX10.6.sdk "-L/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug" "-F/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug" -filelist "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/Objects-normal/x86_64/libssfm.0.LinkFileList" -install_name @executable_path/../Libraries/libssfm.0.dylib -mmacosx-version-min=10.5 -framework GLUT -framework OpenGL -single_module -compatibility_version 1.0 -current_version 1.0 -o "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug/libssfm.0.dylib"
>
>
> Other than that, the project is set to the 10.6 SDK and 10.5 deployment target, and no "Exported Symbols File" is being used for the libssfm dynamic library target.
>
> All of this leads me to believe that Xcode is failing to pass the -fvisibility flag to the compiler (which I can't see anywhere in the compiler calls), unless I'm just missing something incredibly obvious to actually get it there...
>
> Here's how the compilation and nm analysis look when using GCC 4.2 (with "Symbols Hidden by Default" obviously still selected, and intermediary "Clean All" runs as necessary to start afresh):
>
> CompileC "build/NLSE Solver.build/Debug/libssfm.build/Objects-normal/x86_64/ssfm.o" ssfm/ssfm.c normal x86_64 c com.apple.compilers.gcc.4_2
> cd "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver"
> setenv LANG en_US.US-ASCII
> /Developer/usr/bin/gcc-4.2 -x c -arch x86_64 -fmessage-length=0 -pipe -std=gnu99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wmissing-field-initializers -Wmissing-prototypes -Wreturn-type -Wmissing-braces -Wparentheses -Wswitch -Wunused-parameter -Wunused-variable -Wunused-value -pedantic -Wshadow -Wsign-compare -Wnewline-eof -Wshorten-64-to-32 -Wglobal-constructors -isysroot /Developer/SDKs/MacOSX10.6.sdk -mfix-and-continue -msse3 -mssse3 -msse4.1 -msse4.2 -mmacosx-version-min=10.5 -gdwarf-2 -iquote "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-generated-files.hmap" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-own-target-headers.hmap" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-all-target-headers.hmap" -iquote "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/libssfm.0-project-headers.hmap" "-F/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug/include" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/DerivedSources/x86_64" "-I/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/DerivedSources" -c "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/ssfm/ssfm.c" -o "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/Objects-normal/x86_64/ssfm.o"
>
> Ld build/Debug/libssfm.0.dylib normal x86_64
> cd "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver"
> setenv MACOSX_DEPLOYMENT_TARGET 10.5
> /Developer/usr/bin/gcc-4.2 -arch x86_64 -dynamiclib -isysroot /Developer/SDKs/MacOSX10.6.sdk "-L/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug" "-F/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug" -filelist "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/NLSE Solver.build/Debug/libssfm.build/Objects-normal/x86_64/libssfm.0.LinkFileList" -install_name @executable_path/../Libraries/libssfm.0.dylib -mmacosx-version-min=10.5 -framework GLUT -framework OpenGL -single_module -compatibility_version 1.0 -current_version 1.0 -o "/Users/jmpp/Documents/Universidad/Tesis/Software/NLSE Solver/build/Debug/libssfm.0.dylib"
>
>
> -> nm -gm build/Debug/libssfm.0.dylib | grep private
> 0000000000000d0f (__TEXT,__text) external _some_private_symbol
>
>
> So, any pointers as to what I am doing wrong to get the compiler to stop exporting unrequested symbols? Any other information I could provide to help debug the issue...? Thanks in advance!
>
>
> - jmpp
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden