[cfe-dev] Passing -r to the linker

Dale Johannesen dalej at apple.com
Sun Aug 15 11:16:22 PDT 2010


On Aug 15, 2010, at 9:15 AM, Daniel Dunbar wrote:
> On Aug 13, 2010, at 7:25, Dimitry Andric <dimitry at andric.com> wrote:
>>
>> Yes, this is a real difference in command line option processing  
>> between
>> gcc and clang.  Probably for old-time compatibility's sake, gcc just
>> passes unknown options through to the linker, while clang seems to  
>> just
>> swallow them. :)
>
> I don't believe this to be correct. GCC passes *a lot* of options
> through to the linker, buy certainly not all unrecognized options.

Can it be that nobody has tried this yet?

now what? gcc-4.2 -v hello.c -qxysuz
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /var/tmp/gcc/gcc-5666~31/src/configure --disable- 
checking --enable-werror --prefix=/usr --mandir=/share/man --enable- 
languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/ 
$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --program- 
prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686- 
apple-darwin11 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666)
  /usr/libexec/gcc/i686-apple-darwin11/4.2.1/cc1 -quiet -v -imultilib  
x86_64 -D__DYNAMIC__ hello.c -fPIC -quiet -dumpbase hello.c -mmacosx- 
version-min=10.7.0 -m64 -mtune=core2 -auxbase hello -version -o /var/ 
folders/7r/qp6k51002kk8q66xv3dq29=w+++26j/T//ccZ6surA.s
ignoring nonexistent directory "/usr/lib/gcc/i686-apple- 
darwin11/4.2.1/../../../../i686-apple-darwin11/include"
#include "..." search starts here:
#include <...> search starts here:
  /usr/local/include
  /usr/lib/gcc/i686-apple-darwin11/4.2.1/include
  /usr/include
  /System/Library/Frameworks (framework directory)
  /Library/Frameworks (framework directory)
End of search list.
GNU C version 4.2.1 (Apple Inc. build 5666) (i686-apple-darwin11)
	compiled by GNU C version 4.2.1 (Apple Inc. build 5666).
GGC heuristics: --param ggc-min-expand=150 --param ggc-min- 
heapsize=65536
Compiler executable checksum: 0493e38a981908552b45ec7d6d053909
hello.c: In function 'main':
hello.c:1: warning: incompatible implicit declaration of built-in  
function 'printf'
  /usr/libexec/gcc/i686-apple-darwin11/4.2.1/as -arch x86_64 - 
force_cpusubtype_ALL -o /var/folders/7r/qp6k51002kk8q66xv3dq29=w+++26j/ 
T//ccA6bE21.o /var/folders/7r/qp6k51002kk8q66xv3dq29=w+++26j/T// 
ccZ6surA.s
  /usr/libexec/gcc/i686-apple-darwin11/4.2.1/collect2 -dynamic -arch  
x86_64 -macosx_version_min 10.7.0 -weak_reference_mismatches non-weak - 
o a.out -lcrt1.10.6.o -L/usr/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 - 
L/usr/lib/gcc/i686-apple-darwin11/4.2.1/x86_64 -L/usr/lib/i686-apple- 
darwin11/4.2.1 -L/usr/lib/gcc/i686-apple-darwin11/4.2.1 -L/usr/lib/gcc/ 
i686-apple-darwin11/4.2.1 -L/usr/lib/gcc/i686-apple- 
darwin11/4.2.1/../../../i686-apple-darwin11/4.2.1 -L/usr/lib/gcc/i686- 
apple-darwin11/4.2.1/../../.. /var/folders/7r/qp6k51002kk8q66xv3dq29=w+ 
++26j/T//ccA6bE21.o -lSystem -lgcc -lSystem
now what?

So Daniel is correct, at least on Darwin.




More information about the cfe-dev mailing list