[cfe-users] Command to check the 'linker' used(by clang++) for executable creation on Mac OS

Csaba Raduly via cfe-users cfe-users at lists.llvm.org
Wed May 9 12:31:13 PDT 2018


Hi Vinay,

On Tue, May 8, 2018 at 2:41 PM, Vinay Kumar via cfe-users
<cfe-users at lists.llvm.org> wrote:
(snip)
> My query is how to confirm(command to check) if my executable is created
> using ld.lld linker or ld.gold/some other linker? What is the default linker
> 'clang++' uses(command to cross-check) on mac os?
>

If you built the executable yourself, the easiest way is to run the
link command again.
(Delete the executable and build it again).
If the tool is not immediately obvious (i.e. it doesn't say "ld" or
"ld.gold" , but "clang++"),
 copy the link step and paste it into the command prompt and add a '-v' option.
This will tell you which sub-programs your compiler is calling.

For example, if your link step is

$ g++ -o store_a_fn.exe store_a_fn.o

run this instead:

$ g++ -v -o store_a_fn.exe store_a_fn.o
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with:
/cygdrive/i/szsz/tmpp/gcc/gcc-6.4.0-5.x86_64/src/gcc-6.4.0/configure
--srcdir=/cygdrive/i/szsz/tmpp/gcc/gcc-6.4.0-5.x86_64/src/gcc-6.4.0
--prefix=/usr --exec-prefix=/usr --localstatedir=/var
--sysconfdir=/etc --docdir=/usr/share/doc/gcc
--htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin
--host=x86_64-pc-cygwin --target=x86_64-pc-cygwin
--without-libiconv-prefix --without-libintl-prefix
--libexecdir=/usr/lib --enable-shared --enable-shared-libgcc
--enable-static --enable-version-specific-runtime-libs
--enable-bootstrap --enable-__cxa_atexit --with-dwarf2
--with-tune=generic
--enable-languages=ada,c,c++,fortran,lto,objc,obj-c++
--enable-graphite --enable-threads=posix --enable-libatomic
--enable-libcilkrts --enable-libgomp --enable-libitm
--enable-libquadmath --enable-libquadmath-support --disable-libssp
--enable-libada --disable-symvers --with-gnu-ld --with-gnu-as
--with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix
--without-libintl-prefix --with-system-zlib --enable-linker-build-id
--with-default-libstdcxx-abi=gcc4-compatible
Thread model: posix
gcc version 6.4.0 (GCC)
COMPILER_PATH=/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/lib/:/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'store_a_fn.exe' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/collect2.exe -plugin
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/cyglto_plugin.dll
-plugin-opt=/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/lto-wrapper.exe
-plugin-opt=-fresolution=/tmp/ccWxTpxH.res
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lcygwin
-plugin-opt=-pass-through=-ladvapi32
-plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32
-plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc --build-id -m i386pep --wrap _Znwm
--wrap _Znam --wrap _ZdlPv --wrap _ZdaPv --wrap _ZnwmRKSt9nothrow_t
--wrap _ZnamRKSt9nothrow_t --wrap _ZdlPvRKSt9nothrow_t --wrap
_ZdaPvRKSt9nothrow_t -Bdynamic --dll-search-prefix=cyg --tsaware -o
store_a_fn.exe /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../lib/crt0.o
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/crtbegin.o
-L/usr/lib/gcc/x86_64-pc-cygwin/6.4.0
-L/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/lib/../lib
-L/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../lib -L/lib/../lib
-L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../x86_64-pc-cygwin/lib
-L/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../.. store_a_fn.o -lstdc++
-lgcc_s -lgcc -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32
-lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-cygwin/6.4.0/../../../../lib/default-manifest.o
/usr/lib/gcc/x86_64-pc-cygwin/6.4.0/crtend.o
COLLECT_GCC_OPTIONS='-v' '-o' 'store_a_fn.exe' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'



Csaba
-- 
You can get very substantial performance improvements by not doing the
right thing.
   - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformat way
to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)



More information about the cfe-users mailing list