WIP: Initial changes to support macOS build#35
WIP: Initial changes to support macOS build#35gushromp wants to merge 1 commit intoarnetheduck:masterfrom
Conversation
arnetheduck
left a comment
There was a problem hiding this comment.
this is great to see!
I left a few minor comments - in general, I think to get this merged, the steps would be:
- get the non-mac changes merged in a separate PR - ie there's a number of nice fixes and improvements here already, like the handling of the C++ flags, versions etc that prepare us for multi-platform support
- add mac to CI in a matrix build - to begin with, mac should not result in a hard fail (it should continue to show a green checkmark even if mac fails, but it's good to run it at least, to get an idea)
- negotiate a fix for the constant issue - the important part is that it's autogenerated - then it can live either in upstream or in the
.llfile, either is fine
The other thing to look out for is ABI sizes - this is a general concern: if the size of an object is unknown or wrong, it'll result in hard-to-track issues - maybe that's what your crash is about: some stack allocation that is to small because a type is poorly described.
They're hard to track down in general - compiling with -d:nimAbiCheck (or something similar) can sometimes help.
| gcc.linkerexe:"g++" | ||
| gcc.options.always:"-std=c++14" | ||
| gcc.linkerexe="g++" | ||
| gcc.options.always="-std=c++14" |
There was a problem hiding this comment.
with the change to compile, should be able to remove this
|
|
||
| static: | ||
| if not (defined(linux) or defined(macosx)): | ||
| echo "Unsupported platform. Exiting." |
There was a problem hiding this comment.
there's no need to quit in general, even if there's no explicit support for a platform - ie if it breaks, it'll break but maybe it won't
|
|
||
| shift 4 | ||
| cmake -GNinja -DLLVM_USE_LINKER=gold LLVM_INCLUDE_BENCHMARKS=OFF "$@" .. | ||
| cmake -GNinja "$@" .. |
There was a problem hiding this comment.
should continue to use gold on linux and disable benchmarks everywhere
There was a problem hiding this comment.
Yeah sorry I made ADDITIONAL_CMAKE_FLAGS variable on the top and forgot to add it back here. As for deleting LLVM_INCLUDE_BENCHMARKS, I did so because it's already passed from the Makefile to the script.
| proc callErrno(g: LLGen, prefix: string): llvm.ValueRef = | ||
| # on linux errno is a function, so we call it here. not at all portable. | ||
|
|
||
I'll be glad to do so, but please help me understand the scope of the changes you'd like to see in a separate PR - since most of those are
Will do!
The posix constants fall back to
Yeah this has been the most painful part of getting this to work :) I didn't know about the |
really, anything that "already works" but provides infrastructure for multi-platform support - for example the flag changes to |
|
Also, oddly, the test suite / github actions did not run for this PR - wonder what's up with that.. |
|
ok, looks like 523e173 wasn't enough to make CI run - maybe a rebase would help? |
|
actually, it ran after all, and passes - nice - we'll probably need to differentiate skipped-tests between platforms |
| {.passL: "-Wl,--as-needed".} | ||
| {.passL: gorge(LLVMOut & "bin/llvm-config --ldflags").} | ||
| {.passL: gorge(LLVMOut & "bin/llvm-config --system-libs").} | ||
| {.compile("wrapper.cc", "-std=c++14").} |
There was a problem hiding this comment.
and with a small upstream fix, this is not needed either: 4355022
|
Hey, sorry for the delay, I've been quite busy with work and life in general :) Hopefully I'll get to making the necessary changes by the end of this week |
|
hey @gushromp - what's the status of this? |
|
Sorry, life's been hectic recently and I haven't had the time to see this through :( Most of the stuff was working as-is, and I think the things that didn't work were because of ABI inconsistencies. I was planning to switch to the generated POSIX constants/types (which Araq confirmed is probably the way to go on Discord) - that would help especially with AARCH64 but also X86_64 where it currently fails at runtime. If I'm able to continue at some point I'll let you know :) |
What works:
make compare)nlvmself-build works fine)What doesn't:
M1/arm64 yet, though I hope this is just because of ABI incompatibilities in the
posixmodule which I'll try to iron out. In the meantime you can run in x86_64 via Rosetta just fine.Release builds crash with strange segfault on some things I've tested (i.e.
unittestwhen it tries to initialize itself):I'm still trying to investigate and hopefully fix this issue.
Notes:
Nimsubmodule URL to my own fork, to make this branch work. If/when we merge this PR, we should revert it :)posixmodule and change every imported struct definition by hand. It should probably be possible to repurpose thedetecttool to do this boring work automatically for us.macosx_consts.nimin theposixmodule instead.