≡

wincent.dev

  • Products
  • Blog
  • Wiki
  • Issues
You are viewing an historical archive of past issues. Please report new issues to the appropriate project issue tracker on GitHub.
Home » Issues » Bug #2153

Bug #2153: Undefined reference to pthread_* functions in matcher.c

Kind bug
Product Command-T
When Created 2014-02-07T13:33:13Z, updated 2014-03-06T14:52:25Z
Status closed
Reporter ZyX
Tags no tags

Description

When I try to compile Command-T with make it shows

   x86_64-pc-linux-gnu-gcc -shared -o ext.so ext.o match.o matcher.o -L. -L/usr/lib64 -Wl,-R/usr/lib64 -L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,--no-undefined    -Wl,-R -Wl,/usr/lib64 -L/usr/lib64 -lruby18  -lrt -ldl -lcrypt -lm   -lc
   matcher.o: In function `CommandTMatcher_sorted_matches_for':
   matcher.c:(.text+0x3a8): undefined reference to `pthread_create'
   matcher.c:(.text+0x42f): undefined reference to `pthread_join'
   collect2: выполнение ld завершилось с кодом возврата 1
   make: *** [ext.so] Ошибка 1Ошибка

(“выполнение ld завершилось с кодом возврата 1” means “ld returned 1” and “Ошибка” is “Error”).

To fix this I have to use make dldflags=-lpthread. Ruby version is 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]. I did ruby extconfig.rb before doing make, though I did not remove anything that may have been left from the previous compilation.

Comments

  1. Greg Hurrell 2014-02-08T05:58:09Z

    Thanks for the report. I haven't seen this error before, but then, of late I've been compiling against a newer version of Ruby.

    I would expect that MakeMakefile should do the right thing and not attempt to compile in pthread support if it doesn't know how, but maybe something else is required beyond just checking the headers. I do vaguely recall that older versions of Ruby — up until the 1.9 era, I think — are not compiled with pthread support unless you take explicit action to make them do so (and there are a few downsides to doing so, if I recall correctly).

    Here are a couple links about the problems of using pthreads with 1.8:

    • https://access.redhat.com/site/solutions/383883
    • https://bugs.launchpad.net/ubuntu/+source/ruby1.8/+bug/307462

    I am not sure what the best solution is here. We could just hard-code 1.8.7 to not use pthreads, or we could try to come up with a heuristic for deciding when to pass special linker flags through like you did. Thoughts?

  2. Greg Hurrell 2014-03-06T14:52:22Z

    I'm going to close this and merge it into bug #2135 to try and keep all pthread-related bugs in one place.

  3. Greg Hurrell 2014-03-06T14:52:25Z

    Status changed:

    • From: new
    • To: closed
Add a comment

Comments are now closed for this issue.

  • contact
  • legal

Menu

  • Blog
  • Wiki
  • Issues
  • Snippets