This is an archive of the discontinued LLVM Phabricator instance.

[Driver][NetBSD] -r: imply -nostdlib like GCC
ClosedPublic

Authored by brad on Feb 12 2022, 10:22 PM.

Details

Summary

Similar to D116843 for Gnu.cpp

Diff Detail

Event Timeline

brad requested review of this revision.Feb 12 2022, 10:22 PM
brad created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 12 2022, 10:22 PM
joerg added a subscriber: joerg.Feb 13 2022, 1:59 PM

I'm ambivalent about this change. To me, it falls into the category of "stop passing random ld options to the compiler driver".

MaskRay accepted this revision.Feb 13 2022, 11:44 PM

I'm ambivalent about this change. To me, it falls into the category of "stop passing random ld options to the compiler driver".

It's not only about options, but also some crt files. Very few projects assume the behavior and for the few, not implying -nostdlib for -r will cause them some portability inconvenience.
Well, you maintain the NetBSD part and can certainly disagree :)

This revision is now accepted and ready to land.Feb 13 2022, 11:44 PM
joerg added a comment.Feb 14 2022, 2:11 AM

Well, it doesn't work with GCC either, that's why I don't care much about this change. It just attempts to legalize a user bug (using a linker option directly as a compiler flag). But I don't care enough to object either.

Well, it doesn't work with GCC either, that's why I don't care much about this change. It just attempts to legalize a user bug (using a linker option directly as a compiler flag). But I don't care enough to object either.

-r is different from -Wl,-r.
GCC is free to assign specific semantics to -r, like -no-pie, -pie, -shared, to alter crt files and -l libraries a bit.

This revision was landed with ongoing or failed builds.Feb 14 2022, 8:31 PM
This revision was automatically updated to reflect the committed changes.
uabelho added inline comments.
clang/test/Driver/netbsd.c
477

Hi,

I see this CHECK-NOT fail every now and then due to bad luck:

13:48:46 /repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/llvm-main-gcc/clang/test/Driver/netbsd.c:477:21: error: RELOCATABLE-NOT: excluded string found in input
13:48:46 // RELOCATABLE-NOT: crt{{[^.]+}}.o
13:48:46 ^
13:48:46 <stdin>:6:286: note: found here
13:48:46 "/proj/bbi_twh/wh_bbi/x86_64-Linux2/bbigcc/1.9.3.0/crosscompiler/bin/ld" "--sysroot=/repo/bbiswjenk/fem2s10-eiffel176/workspace/llvm/llvm-main-gcc/clang/test/Driver/Inputs/basic_netbsd_tree" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so" "-o" "a.out" "-r" "-r" "/tmp/lit-tmp-crtcq7cs/netbsd-94b421.o"
13:48:46 ^~~~~~~~~~~~~~~~~~~~~~~~

Same thing with

13:59:16 Failed Tests (5):
13:59:16 Clang :: Driver/freebsd.c
13:59:16 Clang :: Driver/fuchsia.c
13:59:16 Clang :: Driver/linux-cross.cpp
13:59:16 Clang :: Driver/netbsd.c
13:59:16 Clang :: Driver/openbsd.c

Perhaps the CHECK-NOT can be made stricter to avoid these matches due to bad luck?

Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2022, 6:05 AM