-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Improve user experience with ldc2, incl. cross-compilation #1755
Conversation
Don't perform the does-default-target-triple-contain-msvc check on non-Windows hosts (which would need a hacked LLVM to return true on other hosts).
Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. |
@@ -42,6 +42,7 @@ enum string platformCheck = q{ | |||
version(Android) ret ~= "android"; | |||
version(Cygwin) ret ~= "cygwin"; | |||
version(MinGW) ret ~= "mingw"; | |||
version(WebAssembly) ret ~= "wasm"; |
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.
This is good for completeness sake, but it won't do much, since it only ever runs when compiling dub itself to WebAssembly.
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.
Nope, this is also mixed into a platform probe file. The compiler compiles that one, using dub's --arch
as LDC -mtriple
, so that the BuildPlatform (parsed from compiler output) will feature a wasm
platform. It's what makes dub 'target-aware'.
Yep, and remove the |
I can see that dub passes the triple to ldc, but it also looks the dflags in the dub.sdl are stripped, including the |
This is basically dlang#1548 with an augmented set of compiler flags being included in the linking command lines.
By treating all 'architectures' containing a `-` as `-mtriple` values. E.g., `dub --arch=wasm32-unknown-unknown-wasm` to cross-compile to WebAssembly. This dub switch is already used when probing the compiler, so the build platform detection works as expected. Also add `wasm` as detected platform and use the .wasm executable file extension (for ldc2). This fixes dlang#1749 when moving the `-mtriple` option from the dub config file to the dub command line.
I don't see how previous dflags wouldn't be applied anymore (after the amended fix wrt. a How is that supposed to work anyway? I mean, each (transitive) dependency of spasm would ideally be compiled with |
With --arch, the build (target) platform might now diverge from the host platform. The compiler's default triple doesn't matter when cross-compiling, so use the <name>.lib MSVC format when targeting Windows but not MinGW. This fixes one aspect of dlang#1599.
No there is not. That is a short coming of dub. Properties are only propagated upwards. With regards to optional, I made a pull request for it to be betterC compatible (and merged). That has worked in the past. But with this pr I get similar errors to you. I looked at the compiler invocations and with the current dub, the optional package isn't actually build for wasm, no triple, no betterC. With this pr the wasm triple gets propagates downwards and causes issues. Well, rightfully so. I made a pr for the optional package to fix its configuration see pull#38 The reason it works is that there are only templates in the package. |
Oh wow, a serious shortcoming indeed. One could apparently work something out with the
This is off-topic, but DMD only supports either |
also off-topic: I have a wip PR in druntime where I define all those things for WebAssembly. Actually I took the WASI headers so it isnt strictly wasm. My reasoning is that is if you are using libc/druntime in wasm, you are actually either targeting WASI or emscripten. And if you don't, you simply dont call them and they will never end up in the binary. Regardless, I don't think setting the Posix version for WebAssembly is the right thing to do. I remember trying it briefly just to get things compiling without betterC, but I abandoned that in favor of wasi. |
If I fix the above mentioned issues with optional (and mir-core as well), I can confirm that dub now sets the file extensions correctly. Then I get this error:
with
|
Ah nice, yeah that's a proper solution. I assume it cannot be tested for regressions though? |
Thx, should be fixed now. |
I have hit that issue before with the dip1000/dip25 compiler flag. The issue was that a dependency had a template which I used in a project where dip1000/dip25 was active. It caused mangling issues because the template called a regular function in the dependency, which had different function attributes inferred on it (IIRC it was the return attribute). The workaround was to use the The obvious solution would be to propagate all dips (or other future compiler feature flags) to all dependencies. But I don't think that will work, as it is perfectly valid for dependencies to not use various compiler feature flags. Although with something as determent as an arch, it seems more than reasonable to propagate it. |
Works! |
Yep, I think there's a class of flags which make perfect sense as base flags, incl. |
…latform runtime checks) Also fixes dlang#1249. For LDC as implicit cross compiler, the file extensions for libraries and object files etc. don't depend on the compiler, but solely on the target. Targets selected with `--arch` are correctly probed by dub, so that the parsed `BuildPlatform` represents the target platform.
@kinke the dub argument for just printing what would be done is |
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.
Not a big deal if the test isn't here IMO, especially given it's currently pretty hard to test this kind of things.
Ping @wilzbach @thewilsonator , it would be great to have this in the next release. |
A new feature right before the release candidate? |
A lot of bug fixes, that only affect LDC, and were PRed by an LDC maintainer. |
This includes dlang/dub#1755 which improves LDC support in general and enables specifying arbitrary LLVM target triples as dub `--arch` option.
This includes dlang/dub#1755 which improves LDC support in general and enables specifying arbitrary LLVM target triples as dub `--arch` option.
Changelog follow-up to #1755 merged-on-behalf-of: Nicholas Wilson <[email protected]>
@kinke - Building with LTO such that it included dependent packages would be very useful. Is this what you have in mind? |
Yes; should be doable today via |
I would also include |
Hm... I thought there was more to it. I'm partly thinking of having dependent packages also pull in phobos/druntime via I'll look into this further and see if it basically takes care of itself or there are other details to be worked through. |
No description provided.