[Driver][Gnu] -r: imply -nostdlib like GCC
authorFangrui Song <i@maskray.me>
Thu, 13 Jan 2022 19:25:23 +0000 (11:25 -0800)
committerFangrui Song <i@maskray.me>
Thu, 13 Jan 2022 19:25:23 +0000 (11:25 -0800)
commit64da6eb06570adf38c96075de0116f6d29d5ba81
tree20c4bc6cdfcf5e0d6bee9ad2576e59ba0be57d7f
parentffee3b2f7a8ef2f488bad422be1901c5efcbd901
[Driver][Gnu] -r: imply -nostdlib like GCC

See `gcc -dumpspecs` that -r essentially implies -nostdlib and suppresses
default -l* and crt*.o. The behavior makes sense because otherwise there will be
assuredly conflicting definitions when the relocatable output is linked into the
final executable/shared object.

Reviewed By: thesamesam, phosek

Differential Revision: https://reviews.llvm.org/D116843
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/linux-cross.cpp