Skip to content
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

gmake fails on FreeBSD #2105

Closed
tschuxxi opened this issue Jul 29, 2017 · 4 comments
Closed

gmake fails on FreeBSD #2105

tschuxxi opened this issue Jul 29, 2017 · 4 comments

Comments

@tschuxxi
Copy link

Hi,

i tried to to build ponyc like described in the readme for FreeBSD but I always get the following error message:

Linking libponyrt.tests
build/release/libponyrt.a(threads.o): In function `ponyint_thread_create':
src/libponyrt/platform/threads.c:(.text+0xd): undefined reference to `pthread_create'
c++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake: *** [Makefile:697: build/release/libponyrt.tests] Fehler 1

I'm running 11.1-RELEASE FreeBSD 11.1-RELEASE with GNU Make 4.2.1

@dipinhora
Copy link
Contributor

@tschuxxi I think we might need to use -pthread instead of -lpthread as an argument to gcc (see https://stackoverflow.com/a/23251828 and https://groups.google.com/forum/#!topic/comp.programming.threads/NCEpG0EOCCY).

Can you try changing the makefile line 352 (https://github.com/ponylang/ponyc/blob/master/Makefile#L352) from:

  llvm.libs += -lpthread -lexecinfo

to:

  llvm.libs += -pthread -lexecinfo

and line 287 in genexe.c (https://github.com/ponylang/ponyc/blob/master/src/libponyc/codegen/genexe.c#L287) from:

    "%s %s %s %s -lpthread %s -lm %s",

to

    "%s %s %s %s -pthread %s -lm %s",

and then compiling to see if it works?

@SeanTAllen
Copy link
Member

@tschuxxi if you can verify this as a fix and get it in soon (next hour or so) it can make it into the 0.16.1 release I am doing soon.

@tschuxxi
Copy link
Author

I changed the files but still get the same error message

@dipinhora
Copy link
Contributor

dipinhora commented Jul 29, 2017

@tschuxxi Thanks for trying and confirming that fix didn't work.

The following makefile fix should resolve the issue (I did a quick test via vagrant):

diff --git a/Makefile b/Makefile
index a20c48fa..abe47cc4 100644
--- a/Makefile
+++ b/Makefile
@@ -465,6 +465,8 @@ ifeq ($(OSTYPE),linux)
 endif
 
 ifeq ($(OSTYPE),freebsd)
+  libponyc.tests.links += libpthread
+  libponyrt.tests.links += libpthread
   libponyc.benchmarks.links += libpthread
   libponyrt.benchmarks.links += libpthread
 endif

The issue was that when linking tests on freebsd, we should be including libpthread or else symbol resolution for pthread functions doesn't work.

If would be ideal if you can confirm the fix and then we can try and get it into the release for 0.16.1 that @SeanTAllen is doing soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants