digitalmars.D.learn - Troubleshooting DUB invocations
- Dukc (11/11) Nov 12 2019 When trying to compile a project including newest Spasm (DUB
- kinke (4/15) Nov 12 2019 Dub is open-source, so you can grep the source. - Dub uses it for
- Dukc (14/17) Nov 13 2019 Thanks. At first it didn't seem to work. Then I realized that the
- Sebastiaan Koppe (12/23) Nov 13 2019 I have seen this error as well. I actually test a few ldc
- Dukc (5/7) Nov 13 2019 Regarding that, perhaps I can save you a bit trouble if you also
- Sebastiaan Koppe (34/42) Nov 18 2019 I have had some time today to look into this. About the
- Dukc (15/43) Nov 19 2019 Yeah, definitely useful if you want to link in, say, a C-borne
- Sebastiaan Koppe (11/41) Nov 19 2019 Well it is, but some versions from the host were still set. E.g.
- Dukc (5/10) Nov 19 2019 But the @disabled function stub (if my thinking is sound) would
When trying to compile a project including newest Spasm (DUB package) using the newest LDC via DUB, the result is: ``` lld: error: unknown argument: --no-as-needed ``` I then ran DUB with -v switch and it turned out the invocation contained `-L--no-as-needed` as first of all the -L arguments. The trouble is, how do I know what causes DUB to add that argument to the invocation? I could find no reason in `dub.<json/sdl>` files of either my package, Spasm or any package in Spasm dependency tree.
Nov 12 2019
On Tuesday, 12 November 2019 at 16:44:06 UTC, Dukc wrote:When trying to compile a project including newest Spasm (DUB package) using the newest LDC via DUB, the result is: ``` lld: error: unknown argument: --no-as-needed ``` I then ran DUB with -v switch and it turned out the invocation contained `-L--no-as-needed` as first of all the -L arguments. The trouble is, how do I know what causes DUB to add that argument to the invocation? I could find no reason in `dub.<json/sdl>` files of either my package, Spasm or any package in Spasm dependency tree.Dub is open-source, so you can grep the source. - Dub uses it for all 3 compilers (e.g., https://github.com/dlang/dub/blob/f87302dd206b0e5871b39704e694b2194e294aa5/source/dub/co pilers/ldc.d#L249), and I'm not sure it's really needed. Anyway, you can also use another linker that supports this flag (e.g., via `-linker=gold`).
Nov 12 2019
On Tuesday, 12 November 2019 at 18:32:32 UTC, kinke wrote:Dub is open-source, so you can grep the source. - Dub uses it for all 3 compilers (e.g., https://github.com/dlang/dub/blob/f87302dd206b0e5871b39704e694b2194e294aa5/source/dub/co pilers/ldc.d#L249), and I'm not sure it's really needed. Anyway, you can also use another linker that supports this flag (e.g., via `-linker=gold`).Thanks. At first it didn't seem to work. Then I realized that the `--link-internally` flag that's specified in `ldc.conf` prevents changing the linker. Took it off, and the gold linker understood the flag in question, but had problems with others. I tried removing some, but there were still more to remove. Getting WASM code to link tends to be trial and error in my experience, so I decided best not to stray far from what Spasm does. I also tried LDC 1.18, but the dub also added that unwanted flag here. I don't wan't to use older LDC than that. However, extracting the LDC invocation and manually calling it without `--no-as-needed` appears to work. Solution? I'm going to write my `build.d` to do just that automatically. Is there an issue about that already, or should I open one?
Nov 13 2019
On Tuesday, 12 November 2019 at 16:44:06 UTC, Dukc wrote:When trying to compile a project including newest Spasm (DUB package) using the newest LDC via DUB, the result is: ``` lld: error: unknown argument: --no-as-needed ``` I then ran DUB with -v switch and it turned out the invocation contained `-L--no-as-needed` as first of all the -L arguments. The trouble is, how do I know what causes DUB to add that argument to the invocation? I could find no reason in `dub.<json/sdl>` files of either my package, Spasm or any package in Spasm dependency tree.I have seen this error as well. I actually test a few ldc versions on the CI, and I always test latest. Currently anything higher than 1.17 is not supported, although it would probably require a small change. Except for the fact that -mtriple gets propagated starting from 1.18 to all dependencies (which is a good thing). This causes issues for some of the dependencies since they have no idea what wasm is. It has been on the back of my mind since 1.18-beta came out. I am going to reserve a little time tomorrow to work on it. Thanks for digging as far as you have.
Nov 13 2019
On Wednesday, 13 November 2019 at 15:41:01 UTC, Sebastiaan Koppe wrote:It has been on the back of my mind since 1.18-beta came out. I am going to reserve a little time tomorrow to work on it.Regarding that, perhaps I can save you a bit trouble if you also try to get 1.19 working: if you get compile errors related to SortedRange, the fix is https://github.com/dlang/phobos/pull/7266.
Nov 13 2019
On Wednesday, 13 November 2019 at 18:10:15 UTC, Dukc wrote:On Wednesday, 13 November 2019 at 15:41:01 UTC, Sebastiaan Koppe wrote:I have had some time today to look into this. About the --no-as-needed: TL;DR: add `--build-mode=allAtOnce` to the dub command. Kinke made some changes in dub to facilitate separate linking for ldc. I am not aware of all the details but the major benefit is that it allows cross compilation with dub and ldc. Because of the separate linking the --no-as-needed turned up. As far as I can see it is only needed when compiling for linux. Which brings up the question, why linux? Aren't we compiling for wasm? Well yes. But that is just the way things worked up until now, ldc and dub just pick the host machine. Luckily there is the new dub `--arch` argument that can take a llvm triple, in our case wasm32-unknown-unknown-wasm. This causes dub not to add the `--no-as-needed`. Except, that it also passes the triple upwards the dependency tree. Now all the dependencies of spasm get compiled targeting wasm. This is a good thing, except that the optional package which spasm depends on fails to compile with it. There is a newer version that fixes the configuration, but that one fails because of the `from.std` import idiom (it imports the std package from phobos which doesn't recognise wasm and fails with "Unknown OS"). In the end it is all caused by phobos and druntime not knowing anything about wasm. Which I am currently working on behind the scenes to fix. In the meantime I am going to make a PR for the optional package to avoid the `from.std` idiom. Although I might end up playing whack-a-mole here, as there might be more dependencies that need a fix now. Another workaround that you can use right now is by adding the `--build-mode=allAtOnce` argument to dub. It effectively gets you the old behaviour. It is what I am using in my CI to get it to go green again.It has been on the back of my mind since 1.18-beta came out. I am going to reserve a little time tomorrow to work on it.Regarding that, perhaps I can save you a bit trouble if you also try to get 1.19 working: if you get compile errors related to SortedRange, the fix is https://github.com/dlang/phobos/pull/7266.
Nov 18 2019
On Monday, 18 November 2019 at 19:35:13 UTC, Sebastiaan Koppe wrote:Kinke made some changes in dub to facilitate separate linking for ldc. I am not aware of all the details but the major benefit is that it allows cross compilation with dub and ldc.Yeah, definitely useful if you want to link in, say, a C-borne wasm binary.Because of the separate linking the --no-as-needed turned up. As far as I can see it is only needed when compiling for linux. Which brings up the question, why linux? Aren't we compiling for wasm? Well yes. But that is just the way things worked up until now, ldc and dub just pick the host machine. Luckily there is the new dub `--arch` argument that can take a llvm triple, in our case wasm32-unknown-unknown-wasm. This causes dub not to add the `--no-as-needed`.That was news to me - I thought everything was always being compiled to WASM.Except, that it also passes the triple upwards the dependency tree. Now all the dependencies of spasm get compiled targeting wasm. This is a good thing, except that the optional package which spasm depends on fails to compile with it. There is a newer version that fixes the configuration, but that one fails because of the `from.std` import idiom (it imports the std package from phobos which doesn't recognise wasm and fails with "Unknown OS").I have sometimes thought that perhaps a static assert isn't the best thing to use for unimplemented features in Phobos, precisely because of this issue. A disabled function stub would serve better, unless I'm missing something.In the meantime I am going to make a PR for the optional package to avoid the `from.std` idiom. Although I might end up playing whack-a-mole here, as there might be more dependencies that need a fix now."ending up"? If it's like what getting Phobos to work has been for me, you're continuing the game, not ending up playing it ;D.Another workaround that you can use right now is by adding the `--build-mode=allAtOnce` argument to dub. It effectively gets you the old behaviour. It is what I am using in my CI to get it to go green again.Do not hurry more than you want -I already got my extract-dub-failure workaround working.
Nov 19 2019
On Tuesday, 19 November 2019 at 12:06:36 UTC, Dukc wrote:On Monday, 18 November 2019 at 19:35:13 UTC, Sebastiaan Koppe wrote:Well it is, but some versions from the host were still set. E.g. version(linux).Well yes. But that is just the way things worked up until now, ldc and dub just pick the host machine. Luckily there is the new dub `--arch` argument that can take a llvm triple, in our case wasm32-unknown-unknown-wasm. This causes dub not to add the `--no-as-needed`.That was news to me - I thought everything was always being compiled to WASM.Either way, as long as there is a clear way to debug why it ended up there. Unlike what we have now where you need to dig endlessly.Except, that it also passes the triple upwards the dependency tree. Now all the dependencies of spasm get compiled targeting wasm. This is a good thing, except that the optional package which spasm depends on fails to compile with it. There is a newer version that fixes the configuration, but that one fails because of the `from.std` import idiom (it imports the std package from phobos which doesn't recognise wasm and fails with "Unknown OS").I have sometimes thought that perhaps a static assert isn't the best thing to use for unimplemented features in Phobos, precisely because of this issue. A disabled function stub would serve better, unless I'm missing something."ending up"? If it's like what getting Phobos to work has been for me, you're continuing the game, not ending up playing it ;D.Yeah it is a pain, and since wasm/betterc isn't tested (or barely), anyone is free to break it. E.g. the recent change to the std.range.chain function, which suddenly wasn't betterC anymore...Sure, but stuff just needs to work. I updated the BUILDING.md file in spasm as well.Another workaround that you can use right now is by adding the `--build-mode=allAtOnce` argument to dub. It effectively gets you the old behaviour. It is what I am using in my CI to get it to go green again.Do not hurry more than you want -I already got my extract-dub-failure workaround working.
Nov 19 2019
On Tuesday, 19 November 2019 at 13:41:32 UTC, Sebastiaan Koppe wrote:But the disabled function stub (if my thinking is sound) would have the advantage that it'd prevent compilation only if called -not if only imported.A disabled function stub would serve better, unless I'm missing something.Either way, as long as there is a clear way to debug why it ended up there. Unlike what we have now where you need to dig endlessly.
Nov 19 2019