Opened 6 years ago

Closed 8 months 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 Revisions:

Description

Hello,

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?

Samuel

Change History (7)

comment:1 Changed 6 years ago by sthibaul

  • Operating System changed from Unknown/Multiple to Other

More precisely, I'm getting

Linking dist-inplace/build/ghc-pkg/ghc-pkg ...
/usr/lib/ghc-6.8.2/lib/unix-2.3.0.0/libHSunix-2.3.0.0.a(Semaphore.o): 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 6 years ago by simonmar

  • Component changed from Compiler to libraries/unix
  • difficulty set to Unknown
  • Milestone set to 6.12.1
  • Priority changed from normal to low

GNU/Hurd eh? Interesting.

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

PTHREAD_CFLAGS=
PTHREAD_LDFLAGS=
PTHREAD_LIBS=
case "$host_os" in
openbsd*)
	PTHREAD_CFLAGS=-pthread
	PTHREAD_LDFLAGS=-pthread
	;;
esac

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

comment:3 Changed 6 years ago by igloo

  • Milestone changed from 6.12.1 to _|_
  • Priority changed from low to normal

comment:4 Changed 4 years ago by jani@…

  • Type of failure set to None/Unknown

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

Look for Invalid in the url below

http://launchpadlibrarian.net/58068323/buildlog_ubuntu-natty-armel.haskell-filestore_0.3.4.2-1_FAILEDTOBUILD.txt.gz

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 4 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 4 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 8 months ago by thomie

  • Resolution set to fixed
  • Status changed from new to closed

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 https://github.com/haskell/unix/issues

Note: See TracTickets for help on using tickets.