-
Notifications
You must be signed in to change notification settings - Fork 43
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
WIP: Initial changes to support macOS build #35
base: master
Are you sure you want to change the base?
Conversation
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 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
.ll
file, 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -58,6 +72,6 @@ mkdir -p $TGT | |||
cd $TGT | |||
|
|||
shift 4 | |||
cmake -GNinja -DLLVM_USE_LINKER=gold LLVM_INCLUDE_BENCHMARKS=OFF "$@" .. | |||
cmake -GNinja "$@" .. |
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.
should continue to use gold
on linux and disable benchmarks everywhere
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.
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.
@@ -2642,10 +2642,14 @@ proc callCtpop(g: LLGen, v: llvm.ValueRef, size: BiggestInt): llvm.ValueRef = | |||
|
|||
proc callErrno(g: LLGen, prefix: string): llvm.ValueRef = | |||
# on linux errno is a function, so we call it here. not at all portable. | |||
|
|||
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.
whitespace
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
)nlvm
self-build works fine)What doesn't:
M1/arm64 yet, though I hope this is just because of ABI incompatibilities in the
posix
module 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.
unittest
when it tries to initialize itself):I'm still trying to investigate and hopefully fix this issue.
Notes:
Nim
submodule URL to my own fork, to make this branch work. If/when we merge this PR, we should revert it :)posix
module and change every imported struct definition by hand. It should probably be possible to repurpose thedetect
tool to do this boring work automatically for us.macosx_consts.nim
in theposix
module instead.