-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][Driver] Support -nostdlib and -nodefaultlibs #108868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
! Check that the libraries do not appear when using -nostdlib and -nodefaultlibs | ||
|
||
! RUN: %flang -### -nostdlib --target=ppc64le-linux-gnu %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=aarch64-apple-darwin %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=sparc-sun-solaris2.11 %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=x86_64-unknown-freebsd %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=x86_64-unknown-netbsd %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=x86_64-unknown-openbsd %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=x86_64-unknown-dragonfly %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=x86_64-unknown-haiku %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nostdlib --target=x86_64-windows-gnu %s 2>&1 | FileCheck %s | ||
|
||
! RUN: %flang -### -nodefaultlibs --target=ppc64le-linux-gnu %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=aarch64-apple-darwin %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=sparc-sun-solaris2.11 %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=x86_64-unknown-freebsd %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=x86_64-unknown-netbsd %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=x86_64-unknown-openbsd %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=x86_64-unknown-dragonfly %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=x86_64-unknown-haiku %s 2>&1 | FileCheck %s | ||
! RUN: %flang -### -nodefaultlibs --target=x86_64-windows-gnu %s 2>&1 | FileCheck %s | ||
|
||
! -lgcc will not be linked on all platforms, so checking for that is redundant | ||
! in certain cases. But it is not clear that it is worth checking for each | ||
! platform individually. | ||
|
||
! CHECK-NOT: "-lFortranRuntime" | ||
! CHECK-NOT: "-lFortranDecimal" | ||
! CHECK-NOT: "-lgcc" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tarunprabhu, @tblah
Shouldn't these be:
Visibility<[ClangOption, FlangOption]>
, it seems likeclang-cl
is now accepting-nodefaultlibs
without diagnostic, and it does not do anything (does NOT add /NODEFAULTLIB to link.exe's command line)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what i was able to tell when I changed this, the lack of an explicit visibility implied these 4, but perhaps I was mistaken. I have no way to test clang-cl. Is there a test for this somewhere?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anything invoking clang-cl if searching for
-nodefaultlibs
in clang tests: https://github.com/search?q=repo%3Allvm%2Fllvm-project+nodefaultlibs+path%3Aclang%2Ftest&type=code. I can check tomorrow (Europe time) if indeed the default visibility extends to clang-cl.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change in Options.td:
I'm getting:
without it I don't get a warning.
The comment at Options.td:74 also seems to suggest the default is only the gcc compatible driver.
llvm-project/clang/include/clang/Driver/Options.td
Lines 74 to 77 in c3536b2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #118640 (comment), can you take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a drive-by comment.
This should be verifiable by checking Options.inc file in the build directory before and after change. Options.inc is the C++ files generated from Options.td when building
clangDriver
. Please use that as your guidance.