c++cgccclang

Use libgcc/compiler-rt altrenative with GCC/Clang


I am writing small low-level runtime library for fun.

According to the libgcc website, low-level runtime library are libraries that compilers generates calls to its routines whenever it needs to perform some operation that is too complicated to emit inline code for. GCC uses this library automatically. Clang uses compiler-rt.

You can use -nostdlib, but that only disables libgcc, I want to use a different (my) library. With clang, I only found out how to use libgcc instead of LLVM's compiler-rt.

How to tell GCC or Clang to use my own library instead of libgcc or compiler-rt?


Solution

  • The command gcc -nostdlib -lyour_lib should work since GCC still uses the calls to the function, and you basically just overwrite their implementation.