When/why does xcode at the C-linker flag -no_deduplicate to C++ MacOS projects?

I have an xcode project I haven't opened in a month or so, and now I get linker warnings about


clang: error: unknown argument: '-no_deduplicate'


The complete linker command is,


/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Content/Code/BirdsEar/BirdsEarApp_Code/Builds/MacOSX/DerivedData/BirdsEarApp8/Build/Products/Debug -F/Content/Code/BirdsEar/BirdsEarApp_Code/Builds/MacOSX/DerivedData/BirdsEarApp8/Build/Products/Debug -filelist /Content/Code/BirdsEar/BirdsEarApp_Code/Builds/MacOSX/DerivedData/BirdsEarApp8/Build/Intermediates/BirdsEarApp8.build/Debug/DiscrReport.build/Objects-normal/x86_64/BirdsEarApp_DiscrTesting.LinkFileList -mmacosx-version-min=10.8 -no_deduplicate -stdlib=libc++ -fobjc-link-runtime -framework WebKit -framework Cocoa -framework Accelerate -framework Carbon -framework IOKit -framework CoreAudio -framework DiscRecording -framework CoreMIDI -framework AudioToolbox -framework QuartzCore -o /Content/Code/BirdsEar/BirdsEarApp_Code/Builds/MacOSX/DerivedData/BirdsEarApp8/Build/Products/Debug/BirdsEarApp_DiscrTesting


Has anyone else seen this?

Who is adding this flag?

Hello all,


I'm still having this problem -- any help??


stp

We got the additional information that it only happens when building the debug configuration; building the release of the app links fine.


HELP!


stp

Hi stpope,


The flag -no_deduplicate is not a clang flag but an OSX ld flag.


If you type man ld on a terminal, you will see the list of parameters and get something like:


     -no_deduplicate
                 Don't run deduplication pass in linker


Normally this flag has an -Xlinker just before. This indicate that the no_duplicate flag is not for the clang driver but for the linker. I read somewhere on the Net that this is a Xcode bug, so maybe you need to update your installation or play with the Linking section in your Build Settings project on Xcode.


Hope this help.


Johan

I believe the -O0 flag (which is common in Debug configurations) winds up trigerring the -no_deduplicate flag. In Xcode, you can check the corresponding settings for optimization. If disabled (-O0), you may get -no_deduplicate.


I encontered the same issue when building from command line using Make. My Makefile sets:

CC=g++

to ensure everything is built with the C++ compiler (ultimately Clang -x c++). g++ is a 'compiler driver' that, in turn, calls the actual compiler or linker. These compiler drivers can translate the command-line flags in unexpected ways.


To resolve this, I revised the make rule I use to build the dylib so it does not pass CFLAGS or CXXFLAGS to the compiler driver. This avoids passing -O0 to the compiler driver. Instead, I pass only LDFLAGS and TARGET_ARCH to the compiler driver. The make rule or dylib I use is based on Make implicit rules for building an executable:


$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -0 $@


Note that to build a dylib requires:

LDFLAGS=-dynamiclib
When/why does xcode at the C-linker flag -no_deduplicate to C++ MacOS projects?
 
 
Q