-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Create libponyc-standalone on MacOS #4303
Conversation
@mfelsche zlib shouldn't be required. i was able to turn it off in the LLVM setup for Linux, well really I turned it off for everything in theory. But that was for LLVM 12. I think there should be a way (probably additional option in LLVM that changed in LLVM 13 or 14) to not require. https://github.com/ponylang/ponyc/blob/main/lib/CMakeLists.txt#L143 and 144 were what was required as of LLVM 12. Note that prior to LLVM 12, only Line 143 was required. |
# on macos we dont have no static libc++ | ||
# so when we want to use this lib | ||
# we need to additionally link libc++ and libz (for llvm) | ||
file(GLOB_RECURSE LLVM_OBJS "${PROJECT_SOURCE_DIR}/../../build/build_libs/llvm/src/llvm//lib/libLLVM*.a") |
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.
I can't remember why, but the GLOB_RECURSE had problems on Linux once I started using.
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.
It is finding all the libs and the resulting static library has all we need. And this is scoped to Darwin only, so, unless this becomes a problem on M1 mac, i think this is fine, but thanks for the heads-up.
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.
How was this tested on MacOS?
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.
It was tested by taking a pony program and linking it to the resulting libponyc-standalone.a
.
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.
what program? does the program fully exercise the API or could there be errors that get hidden by dead code elimination?
Hi @mfelsche, The changelog - added label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do. Release notes are added by creating a uniquely named file in the The basic format of the release notes (using markdown) should be:
Thanks. |
lib/CMakeLists.txt
Outdated
@@ -141,7 +141,7 @@ set(LLVM_INCLUDE_BENCHMARKS OFF) | |||
set(LLVM_INCLUDE_TESTS OFF) | |||
set(LLVM_TOOL_REMARKS_SHLIB_BUILD OFF) | |||
set(LLVM_ENABLE_ZLIB OFF) | |||
set(LLVM_ENABLE_ZLIB:STRING OFF) |
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.
was this tested on Linux? this doesn't seem correct. that we now have LLVM_ENABLE_ZLIB OFF and "OFF".
If it was tested, how was it tested?
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.
Ive found something concerning with this @mfelsche. So locally using the latest pre-packaged ponyc, I can't link the "work" branch of ponydoc due to zlib linking errors, but if I build from source with the exact same LLVM settings, it works, so... there seems to be something going on that i'm unsure about but that is making testing hard and is quite possibly impacting on anyone who tests this PR (including you).
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.
It was tested by taking a pony program and linking it to libponyc-standalone.a
and trying to compile it successfully.
Take this one as a minimal example:
use "lib:ponyc-standalone"
actor Main
new create(env: Env) =>
env.out.print("it works")
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.
that's not sufficient to test for linker errors. if it doesn't exercise the various functions that need say, zlib, then this won't show any linker errors. try testing with the work
branch of ponydoc. You'll need to update the Makefile to use a your ponyc and then can do make
to try building ponydoc. If it compiles and links you should be good at least on your test machine.
Also note, for others in the future, if you don't have zlib installed in a way that llvm can detect then you can have incorrect entries for turning off ZLIB in the LLVM setup and you won't be able to detect in your test environment.
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.
So locally using the latest pre-packaged ponyc, I can't link the "work" branch of ponydoc due to zlib linking errors
I am able to reproduce this issue. I was always testing this with the ponyc that i built in the project. The ponyc installed with ponyup didn't work for me. We can (and should) investigate this in another PR.
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.
Ive found something concerning with this @mfelsche. So locally using the latest pre-packaged ponyc, I can't link the "work" branch of ponydoc due to zlib linking errors, but if I build from source with the exact same LLVM settings, it works, so... there seems to be something going on that i'm unsure about but that is making testing hard and is quite possibly impacting on anyone who tests this PR (including you).
The issue that I found that folks need to be aware of for testing is that your test environment must have Zlib installed in a way that LLVM finds it otherwise, no amount of screwing up the LLVM config will result in the errors.
I think before we merge this PR we should have a test in place as part of our CI that verifies that we have this working for supported platforms (Linux and MacOS). There's some serious ways to mess up the CI setup though that would need to be resolved.
I think we should have that CI support as you opened this PR as there is now someone other than me who would be relying on the standalone library working and not getting broken (which appears to be easy to mess up).
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.
on MacOS the combination of:
set(LLVM_ENABLE_ZLIB OFF)
set(LLVM_ENABLE_ZLIB:STRING OFF)
resulted in llvm still requiring libz. Only this worked for me on MacOs:
set(LLVM_ENABLE_ZLIB OFF)
set(LLVM_ENABLE_ZLIB "OFF")
Linux still needed the version without the quotes. It could also be a difference in cmake versions used on both systems...
I just tested existing libponyc-standalone on linux with the "work" branch of the ponydoc repo and it doesn't link due to zlib, so, we have a general issue with that being broken that I am looking into. I think it would be good to have a conversation at sync about how we can keep libponyc-standalone from getting broken with LLVM upgrades. |
A more full-blown example to use for checking this on a mac is this one: https://github.com/mfelsche/pony-ast/blob/main/examples/compile/compile.pony It can be executed e.g. like this (It needs the
|
@mfelsche That runs OK for me and prints "OK". I wasn't able to make it work for a "bad" project that contains compilation errors. Is that expected? This is what I get:
|
@mfelsche and I have figured out the "why isn't this working" fuckery. PRs will be coming of which, this PR will be one. |
@SeanTAllen @ergl this should do the trick: #4303 (comment) |
@ergl if you see There is a PR in the pipeline for fixing this. Right now the lib only works with a debug build of ponyc. But the fact that it printed |
@mfelsche I think that this information: should be worked into the release notes. |
It will not link libstdc++ statically, as this is not available on osx. When linking against libponyc-standalone one also needs to link against libc++ and libz, but at least we have all the llvm symbols in there.
Co-authored-by: Sean T Allen <[email protected]>
Co-authored-by: Sean T Allen <[email protected]>
18f7487
to
4ac6caa
Compare
@ergl this is ready for testing. |
Confirmed that this works. I was able to follow @mfelsche's advice of using a debug build of ponyc, and now compile also shows the correct errors:
|
It will not link libstdc++ statically, as this is not available on MacOS. When linking against libponyc-standalone one also needs to link against libc++, but at least we have all the LLVM symbols in there.
An example pony program linking against it would need to look like this:
While i think this is acceptable, as those libs are always available on MacOS, i would be happy about any hint on how to include those in
libponyc-standalone
.I was not able to test this on an M1 mac.