-
Notifications
You must be signed in to change notification settings - Fork 143
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
LLVM backend: on Windows use clang instead of llc #279
base: master
Are you sure you want to change the base?
Conversation
I believe FreeBASIC should use LLMV directly, not indirectly through CLang. |
With a few fixups, I was able to compile and run a simple program on windows using Following is the results of what didn't work, and then what did work. In this PR: I then tried a simple program
I tried
|
Thanks for the testing. I tried cross-compiling to win32 from linux and was able to reproduce those errors. I realised from a web search that the problem is clang outputting directives which are not supported by mingw, because it defaults to a platform other than win32 (including presumably clang from emscripten installed on Windows). Passing a more complete --target to clang fixes the problem (and it then fails due to the name mangling). I'm going to also rework this patch to do a runtime fallback to clang instead of hardcoding on win32. As for the #if, oops. I don't understand how you escaped the names to fix the name mangling, and it's totally independent of this patch. Could you please commit the fix for that separately? |
Actually I guess your escaping of the names was a hack, and we instead just need to find the right place to disable fbc adding the suffix? |
I'm working on a fix for escaping the procedure names in |
I think we need to escape global names for windows targets on LLVM.
Using this method from https://llvm.org/docs/LangRef.html for escaping.
|
FYI, I was thinking of something kind of like the following. I have this feeling that will need to track more information about tools and how to run them and a table might help that can be extended. Additional fields could be added instead having only the last tool info cached in
|
So are you working on this? Another usecase is that (on FreeBSD) it may be necessary to ask gcc what the correct path to as and ld are, rather than just running as/ld. I was just going to put that as a special case in fbcFindBin. |
I started to work on it when reviewing this PR to remove the Yes, initial value of For specific behaviours like for FreeBSD: if it's host specific, then I suppose that could be |
@rversteegen another option if you interested in wrapping up this PR. Is just make the changes for clang, and can deal with I've pushed changes to fbc/master for escaping procedure names on llvm+win32 [12a4d28] |
I've made changes in #334 to modify fbc's internals for tool usage. |
Oh wait, hold on. I'm still going to do the rebase. This needs more testing for windows. |
llc.exe is not included with the LLVM official Windows binaries. clang can compile .ll files too but requires different args. This behaviour is gated by __FB_WIN32__ because there doesn't seem to be an existing way to check whether a tool exists. It would be better to fallback to clang only if llc doesn't exist (for example I see it is missing from at least some Android NDK toolchains too). Tested on Linux, not Windows.
llc.exe is not included with the LLVM official Windows binaries. clang can
compile .ll files too but requires different args.
This behaviour is gated by
__FB_WIN32__
because there doesn't seem to be anexisting way to check whether a tool exists. It would be better to fallback to
clang only if llc doesn't exist (for example I see it is missing from at least
some Android NDK toolchains too).
Tested on Linux, not Windows.
C.f. https://www.freebasic.net/forum/viewtopic.php?p=278824#p278824