- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 267
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
Predefine version FreeStanding
when targeting bare-metal
#3608
Conversation
@@ -2,13 +2,16 @@ | |||
// RUN: %ldc -mtriple=x86_64 -c -w %s | |||
// RUN: not %ldc -mtriple=x86_64 -c -w -d-version=WithSynchronized %s 2>&1 | FileCheck %s |
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.
hm, I always thought that specifying a triple without the 2nd/3rd parts would select the default for the host OS, instead of selecting "no OS"....
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.
See Clang's documentation https://clang.llvm.org/docs/CrossCompilation.html#target-triple
Clang also uses the default when a triple part is empty, instead of assuming none
.
-ffreestanding
is what we should implement, in my opinion.
See also: https://chromium.googlesource.com/external/llvm.org/clang/+/google/stable/test/CodeGen/PR3589-freestanding-libcalls.c
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.
Clang also uses the default when a triple part is empty, instead of assuming
none
.
Doesn't seem to be the case: https://cpp.godbolt.org/z/ThW5jW. I think -march=x86-64
is to be used when only wanting to target another arch, with the same host OS and environment.
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.
Ah OK. Indeed.
I presume FreeStanding
can be used to disable all parts of druntime that depend on a host OS. So it'd be good to be able to still set the arch without changing OS.
Is LDCs behavior changed now? (e.g. that before -mtriple=x86_64
would still compile-in all Linux/Windows/... parts.)
Don't think so right?
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.
Nothing has changed (FreeStanding
isn't used anywhere in druntime/Phobos yet); Windows
, linux
, OSX
etc. haven't been predefined before either. I think it just might make disabling parts you've mentioned easier.
void foo() {} | ||
|
||
version (WithSynchronized) | ||
void bar() | ||
{ | ||
__gshared int global; | ||
// CHECK: unknown_critical_section_size.d(12): Error: unknown critical section size for the selected target |
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.
fyi, FileCheck has @LINE
for such cases: ...size.d([[@LINE+1]]): Error...
http://llvm.org/docs/CommandGuide/FileCheck.html#filecheck-pseudo-numeric-variables
Resolves #3607.
This has been added 5+ years ago with dlang/dlang.org@4c9a20a.