-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
Alpine Linux compatibility for pony #1844
Conversation
src/libponyc/codegen/genexe.c
Outdated
@@ -277,6 +278,9 @@ static bool link_exe(compile_t* c, ast_t* program, | |||
#ifdef PONY_USE_LTO | |||
"-flto -fuse-linker-plugin " | |||
#endif | |||
#if defined(PLATFORM_IS_ALPINE_LINUX) || defined(PLATFORM_IS_FREEBSD) |
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.
Quick thought: could PLATFORM_IS_ALPINE_LINUX
be named PLATFORM_IS_MUSL_LINUX
, and still be correct?
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.
@jemc This is unlikely to be correct. See the note in my main PR comment about libexecinfo
/execinfo.h
. Additionally, there is no way to detect that the libc being used is musl
(see: http://wiki.musl-libc.org/wiki/FAQ#Q:_why_is_there_no_MUSL_macro_.3F).
The way this is currently detected is via a Makefile
check for the existence of /etc/alpine-release
and is tied to the Alpine Linux distribution.
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.
Highly disagree with this, as it also breaks cross-compilation. This should be properly detected through a test checking if a symbol in <execinfo.h>
can be resolved by the linker without any additional libraries, and then with -lexecinfo
if it can't.
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.
@shizmob I agree that the best solution is to do a test and then base a decision on that however that was going to add a level of complexity into the ponyc linking code that I wasn't comfortable with. If others agree that's the route desired, then we can implement the appropriate solution.
Can you give me an example set of steps/commands to reproduce where it breaks cross-compilation?
Cooool! |
|
@sylvanc Maybe I'm misunderstanding things but
I agree that the |
f1cd4d0
to
9d79bd6
Compare
@sylvanc I've made a change to how the This has removed the dependency on the Please let me know if this is an acceptable solution or if you have further suggestions for improving things. |
hi, i merged the llvm changes needed in alpine. are you guys interested in integrating ponyc into alpine itself officially, yet? |
@kaniini, we are super interested in integrating ponyc into alpine itself officially! Sorry for the late response on this. What's the process? |
@dipinhora this looks great! Let's merge it. |
@sylvanc right now just somebody showing up with an APKBUILD willing to maintain the packaging. we prefer upstream devs (or those with close ties to upstreams) where possible. |
@kaniini - thanks for the info. I don't know if anyone is in a good position to step up and volunteer for maintaining the APKBUILD, but it's something I might do at some point in the future, if no one else has stepped up before then. |
Is there a reason this hasn't been merged yet? |
@dipinhora can you rebase this so we can merge? |
Changes related to getting pony compiling and running on Alpine Linux Edge. * Define `_GNU_SOURCE` so musl glibc compatibility is enabled. * Makefile changes to detect Alpine Linux and link in `libexecinfo`. * Makefile changes to define PONY_NO_ASSERT for libponyrt-pic. * Changes to stop using glibc specific `__GNUC_PREREQ` macro. * Changes to move Linux cpu affinity setting outside of thread creation function and into same set affinity function as for other platforms. This also includes enabling asio thread affinity setting for non-linux platforms. * Rename `SCHED_BATCH` to `PONY_SCHED_BATCH` to avoid conflict with musl. * Set `this_scheduler` thread-local variable to `NULL` on `ponyint_sched_init` to avoid segfault in running codegen test suite. * Change `#if` for `pony_assert` to use normal `assert` for builds that define `PONY_NO_ASSERT` (`libponyrt` and `libponyrt-pic` only as of this commit) instead of the custom `pony_assert_fail` that prints backtraces. Resolves ponylang#1729
Rebased. |
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.
Looks good to me.
Changes related to getting pony compiling and running on Alpine
Linux Edge.
_GNU_SOURCE
so musl glibc compatibility is enabled.libexecinfo
__GNUC_PREREQ
macrolibexecinfo
if on Alpineor FreeBSD (this is likely also needed but untested)
creation function and into same set affinity function as for
other platforms. This also includes enabling asio thread affinity
setting for non-linux platforms.
SCHED_BATCH
toPONY_SCHED_BATCH
to avoid conflict withmusl.
this_scheduler
thread-local variable toNULL
onponyint_sched_init
to avoid segfault in running codegen testsuite.
Resolves #1729
NOTE: This is unlikely to make pony compatible with all musl based distributions/compiling attempts because pony still relies on
execinfo.h
andmusl
doesn't provide that. Some distributions includelibexecinfo
(as Alpine did) but others (ubuntu
for example) may not. According this post (http://www.openwall.com/lists/musl/2015/04/10/2) in themusl
mailing list, the appropriate longer term solution might be to uselibunwind
./cc @sylvanc (for a review of the affinity changes in particular and everything in general)
/cc @Praetonus (for a review of the
this_scheduler
andexecinfo
stuff in particular and everything in general)Tested using the following in
docker run --privileged -it --rm alpine:edge sh
on anUbuntu 16.04 VM
:apk add --update alpine-sdk libressl-dev cmake binutils-gold llvm llvm-dev pcre2-dev less libexecinfo-dev
#undef open64
to:
/usr/include/llvm/Analysis/TargetLibraryInfo.h
(around line 28)This is only needed until the changes in {main,testing}/{llvm,llvm3.9,llvm4}: Additional musl related fixes alpinelinux/aports#1273
are merged.
coreutils
for process monitor tests to pass or else they have an issue with/bin/cat
being a link:apk add --update coreutils
git clone https://github.com/ponylang/ponyc
make test
(this will fail due to the unresolved PIC/PIE issues; see Always use --pic when using GCC on Linux #1811 and Unable to link Pony programs with gcc defaulting to PIE #1484)./build/release/ponyc -d --pic packages/stdlib
./stdlib