Skip to content
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

Merged
merged 1 commit into from
Nov 7, 2020

Conversation

kinke
Copy link
Member

@kinke kinke commented Nov 7, 2020

Resolves #3607.

This has been added 5+ years ago with dlang/dlang.org@4c9a20a.

Verified

This commit was signed with the committer’s verified signature. The key has expired.
cytopia cytopia
@thewilsonator thewilsonator merged commit 6343bf0 into ldc-developers:master Nov 7, 2020
@kinke kinke deleted the fix3607 branch November 7, 2020 12:44
@@ -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
Copy link
Member

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"....

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FreeStanding version support
3 participants