Opened 9 years ago

Closed 4 years ago

#3178 closed bug (fixed)

Fix linking -lpthread for semaphores

Reported by: sthibaul Owned by:
Priority: normal Milestone:
Component: libraries/unix Version: 6.10.2
Keywords: Cc:
Operating System: Other Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #4523 Differential Rev(s):
Wiki Page:



On the GNU/Hurd OS, the posix semaphore library does not link because of undefined reference to sem_* functions. I do not know how the ghc build process works, could it be that it forgets to use -lpthread for that library?


Change History (7)

comment:1 Changed 9 years ago by sthibaul

Operating System: Unknown/MultipleOther

More precisely, I'm getting

Linking dist-inplace/build/ghc-pkg/ghc-pkg ... /usr/lib/ghc-6.8.2/lib/unix- In function `s1Zi_entry': (.text+0x1947): undefined reference to `sem_unlink'

Yes, I'm currently building 6.10 using the already-compiled 6.8

comment:2 Changed 9 years ago by simonmar

Component: Compilerlibraries/unix
difficulty: Unknown
Milestone: 6.12.1
Priority: normallow

GNU/Hurd eh? Interesting.

You probably need to modify the file libraries/unix/, around line 208:

case "$host_os" in

Please make the change, test it, and send us a patch. Thanks!

comment:3 Changed 9 years ago by igloo

Milestone: 6.12.1_|_
Priority: lownormal

comment:4 Changed 8 years ago by jani@…

Type of failure: None/Unknown

There are very similar errors to this while building haskell packages on Ubuntu/ARM

Look for Invalid in the url below

do you think it needs the same treatment as openbsd? (the comment 'pthread goo' does not make it clear if that workaround is for similar reasons)

Can the passing of flags to gcc be controlled from the commandline or environment without rebuilding ghc6?

comment:5 Changed 8 years ago by jani@…

If I use gcc-4.4 this works fine, it occurs only with 4.5 as it is in Ubuntu 11.04 devel. The flag that apparently causes it is --no-add-needed . Running the gcc command without that flag leads to successful linkage. I am not sure why this is ARM only and whether it is a gcc or ghc6 issue mostly? Should pthread be explicitly mentioned in the link list? I see that it gets linked to the final executable when the build works.

comment:6 Changed 8 years ago by simonmar

This one should be moved to a different ticket. Although the errors are the same, the original ticket here was against GNU/Hurd and I strongly suspect the causes are different. Could you open another ticket with the details? Thanks!

comment:7 Changed 4 years ago by thomie

Resolution: fixed
Status: newclosed

This issue should be fixed together with ticket #4523, commit dd0178b.

Proper autoconf test for sem_close's library; fixes trac #4523

Note: the current issue tracker for the unix library is at

Note: See TracTickets for help on using tickets.