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
cl.exe c:crystalllvm-10.0.0.srcReleaseinllvm-config.exe --libs --system-libs --ldflags 2> /dev/null
#9089
Comments
It shouldn't be there on any platform to be honest, but everything's broken anyway. Makefiles work on windows with As for llvm-config, it can be run during the compile on windows, just remove the quotes. |
@oprypin Thank you for everything you've done lately for Windows support. It seems you took charge of it and you are doing great! I'm so happy this is almost the final step. What do you think of compiling it like:
That way the linker flags can be specified outside of the code, and they can be computed in any way before passing it to the program. Do you think that could work? |
@asterite that works as a hack but It's obviously not a long-term solution. Better hacks to Just Make It Link exist already. |
Why is it a hack? What's a way to configure linker flags associated to each lib? Like with the |
Oh right! I think I misunderstood what you meant! I proposed something similar in #8972 (comment), but I haven't got around to implementing it yet. Having the defaults baked into code is a must, because otherwise the crystal toolchain is hard to use, but being able to override is also neccesary. |
I think specifying the libraries to link within the code is very nice. So I'm still hoping for a solution that is "nice" in that regard. That Btw I don't know if I'm doing something wrong but I get quite different results from
I don't know really. |
This is a hack to get the compiler to compile itself on Windows without interventions. See crystal-lang#9089
I am looking for a way to avoid declaring the dependency on "stdc++" within Crystal code, when really it's the obj file depending on it. Is there any way to compile an equivalent of llvm_ext.cc in a way that it declares the dependency on "stdc++"? |
Oh I see. Building a shared library is the only way to achieve that, and I guess we don't want that. |
Hi @oprypin i have working compiler on windows for some time, don't remember if i address problems you described here, but linker work just fine for me. Please feel free to see this branch: https://github.com/jan-zajic/crystal/commits/feature/win_preview and see if you already addressed same issues, cherry pick some commits if you like, or get inspired. For example here are some nmake build scripts: jan-zajic@4e0d1e6 . Or here jan-zajic@c3f212c (use linker directly on windows and use CRYSTAL_LIBRARY_PATH) I'm sorry for late comment, i don't have time to keep up with your contribution speed right now because my regular work... |
For the most part looks like crystal@master has progressed past the state of your branch (yes, sadly I hadn't seen it), though it has some nice ideas for improvements that I originally managed to do without. In particular, it doesn't seem like you had a goal of using Crystal on Windows to compile the compiler. This problem is specific to that, so it's also not surprising that it's not addressed in your branch. I have resolved this, anyway, but haven't closed the issue because maybe it's not the best solution. |
Declaring the Obviously it needs to be removed on windows though. |
As far as I can see, this has mostly been resolved by #9106 and some other PRs. Is there anything left to do here? |
With PR #9054 in (currently declared as the last step for bootstrapping the compiler on Windows), one can almost almost compile the compiler for Windows and then on Windows, but at the end, the following is passed to the linker as part of the command line:
cl.exe
[…]C:\crystal\src\llvm/ext/llvm_ext.o `c:crystalllvm-10.0.0.srcRelease�inllvm-config.exe --libs --system-libs --ldflags 2> /dev/null` stdc++.lib
[…](sure, one can edit that and run the linker manually, which works, but that kinda sours the experience)
Let's break this one down.
llvm-config
The main culprit, of course, is this line:
crystal/src/llvm/lib_llvm.cr
Line 12 in 1b62767
lib
is involved, we should insert a POSIX shell command expansion into the linker command:\c
→c,\b
→backspace, etc. but that's easy to fix with correct interpolation, whatever.Sooo yes, we can't do it like this on Windows, at all. I'm kinda blanking on what the alternative solution would be. That's why I created this issue rather than just fixing it.
We need to not rely on shell expansion and in general
ldflags
is not cross-platform.We could devise a custom way to do intentional delayed expansion of a subcommand within the linker command, but it's messy.
llvm_ext
Then there's also the other part to this but it's really minor in comparison:
crystal/src/llvm/lib_llvm_ext.cr
Line 2 in 1b62767
stdc++.lib
And I guess this shouldn't be there on Windows?
crystal/src/llvm/lib_llvm.cr
Line 8 in 1b62767
The text was updated successfully, but these errors were encountered: