Bug 218885 - lang/mono: WITH_LLD_IS_LD: pthread_support: error: failed to compute relocation: R_X86_64_DTPOFF64
Summary: lang/mono: WITH_LLD_IS_LD: pthread_support: error: failed to compute relocati...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: David Naylor
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-04-26 12:08 UTC by O. Hartmann
Modified: 2018-06-19 01:20 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (mono)


Attachments
Fix linking with lld (555 bytes, patch)
2017-05-01 17:28 UTC, David Naylor
no flags Details | Diff
lang/mono: set LLD_UNSAFE (1.09 KB, patch)
2017-08-22 20:10 UTC, Ed Maste
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description O. Hartmann 2017-04-26 12:08:21 UTC
On recent CURRENT (FreeBSD 12.0-CURRENT #16 r317435: Wed Apr 26 10:22:35 CEST 2017 amd64) with WITH_LLD_IS_LD enabled, port lang/mono fails via compiling on the host itself (make in ports tree) and via poudriere with the error shown below, which I believe is caused by LLVM 4.0.0/LLD):

[...]
libtool: link: cc -shared  -fPIC -DPIC  -Wl,--whole-archive ./.libs/libmini.a ../../mono/metadata/.libs/libmonoruntime.a ../../mono/io-layer/.libs/libwapi.a ../../mono/utils/.libs/libmonoutils.a /usr/ports/lang/mono/work/mono-4.6.2/eglib/src/.libs/libeglib.a ../../libgc/.libs/libmonogc.a -Wl,--no-whole-archive  -L/usr/local/lib -L../../eglib/src -lm -linotify  -O2 -O3 -fstack-protector -fstack-protector -pthread -pthread   -pthread -Wl,-soname -Wl,libmonoboehm-2.0.so.1 -o .libs/libmonoboehm-2.0.so.1.0.0
error: failed to compute relocation: R_X86_64_DTPOFF64
/usr/bin/ld: error: pthread_support.c:218: can't create dynamic relocation R_X86_64_TLSLD against symbol 'GC_thread_tls' defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
Comment 1 Ed Maste freebsd_committer freebsd_triage 2017-04-26 17:01:38 UTC
Related issues:

Fix for building on large memory systems: https://github.com/emaste/freebsd-ports/commit/192b44c2a6bb83ab0407e7a5dc3e0ddf80326f13

Upstream mono bug: https://bugzilla.xamarin.com/show_bug.cgi?id=49218
Comment 2 David Naylor freebsd_committer freebsd_triage 2017-05-01 17:28:50 UTC
Created attachment 182230 [details]
Fix linking with lld

Please test the attached patch.  It works on FreeBSD/11 (GNU ld 2.17.50) and mono the tests pass :-).
Comment 3 commit-hook freebsd_committer freebsd_triage 2017-05-13 07:48:36 UTC
A commit references this bug:

Author: dbn
Date: Sat May 13 07:48:29 UTC 2017
New revision: 440759
URL: https://svnweb.freebsd.org/changeset/ports/440759

Log:
  Update mono and related ports

  USES=mono: minor fixes
   - save a copy of the nuget package in the packages directory
   - force linking of directories, allowing nuget-extract to be rerun
     without `make clean`
   - fix makenuget: nuget requires an equals to identify the version, not a dash

  devel/monodevelop: update to 6.2.1.3
   - update nuget packages:
     - link older System.Collection.Immutable 1.1.37 to newer 1.3.1 (used
       by C# and F# respectively)
   - update external github repositories
   - allow post-extract target to be run multiple times
   - change MonoDevelop.Packaging to use a newer version of
     NuGet.Build.Packaging (the older version is no longer fetchable)
   - remove patch integrated upstream
   - moved `nuget restore` patching from post-patch into a patch file (the
     former broke silently)
   - ChangeLog:
     - https://developer.xamarin.com/releases/studio/xamarin.studio_6.2/xamarin.studio_6.2/

  irc/smartirc4net: update to 1.1
   - add LICENSE

  lang/fsharp: update to 4.1.18
   - add test dependency on libgdiplus
   - update nuget packages
   - update test paths for fsharp assemblies
   - update patches to prevent `nuget restore` from running
   - ChangeLog:
     - Set executable bit correctly on output
     - Integrate visualfsharp
     - Fix regression on binding redirects for System.Collections.Immutable
     - Fix regression in Microsoft.Build.FSharp.targets
     - Fix binding redirects for System.Collections.Immutable
     - Fix version of library going in %PREFIX/lib/mono/fsharp
     - Align fsc task and target file
     - Use install layout that includes mono/fsharp
     - Fix F# Intereactive on Mono 4.9+
     - Update compiler tools
     - Updates to FSharp.Core nuget package for F# 4.1
     - Fix #656: error FS0193: internal error: No access to the given key

  lang/mono: various fixes
   - fix linking with lld [1]
   - double maximum handle size [2]
   - add option to run acceptance tests
   - allow for optional bootstrapping of mono via either installed mcs (if
     available) or via downloaded "monolite" (default)
   - add python and py-pillow as dependencies for bin/mono-heapviz
   - add armv6 as a supported architecture (untested)
   - switch to github for source code:
     - official tarball does not include tests
   - patches:
     - recognise FreeBSD for AOT suffix
     - change mono-heapviz to use pillow instead of PIL

  multimedia/banshee: tell portscout to ignore this port
   - Portscout was not skipping the 2.9.1 version, and upstream appears to be
     quiet for the last few years.

  x11-toolkits/gtk-sharp20: update to 2.12.43
   - ChangeLog:
     - fix compilation on mono-4.8.0 (incorrect use of sizeof())
     - correctly set owned=true on custom constructors

  PR:		218885 [1]
  PR:		200937 [2]

Changes:
  head/Mk/Uses/mono.mk
  head/devel/monodevelop/Makefile
  head/devel/monodevelop/distinfo
  head/devel/monodevelop/files/patch-Makefile.am
  head/devel/monodevelop/files/patch-external_fsharpbinding_.paket_paket.targets
  head/devel/monodevelop/files/patch-external_fsharpbinding_MonoDevelop.FSharpBinding_FSharpTextEditorCompletion.fs
  head/devel/monodevelop/pkg-plist
  head/irc/smartirc4net/Makefile
  head/irc/smartirc4net/distinfo
  head/irc/smartirc4net/files/
  head/irc/smartirc4net/pkg-plist
  head/lang/fsharp/Makefile
  head/lang/fsharp/distinfo
  head/lang/fsharp/files/patch-Makefile
  head/lang/fsharp/files/patch-Makefile.in
  head/lang/fsharp/files/patch-src_FSharpSource.targets
  head/lang/fsharp/pkg-plist
  head/lang/mono/Makefile
  head/lang/mono/distinfo
  head/lang/mono/files/patch-configure.ac
  head/lang/mono/files/patch-mono_utils_mono-compiler.h
  head/lang/mono/files/patch-mono_utils_w32handle.c
  head/lang/mono/files/patch-scripts_mono-heapviz
  head/lang/mono/pkg-plist
  head/multimedia/banshee/Makefile
  head/x11-toolkits/gtk-sharp20/Makefile
  head/x11-toolkits/gtk-sharp20/distinfo
Comment 4 David Naylor freebsd_committer freebsd_triage 2017-05-13 07:51:47 UTC
Fixed in ports.  Upstream has changed their approach for mono 5 and no longer have this issue.
Comment 5 O. Hartmann 2017-05-14 14:27:03 UTC
OS:  FreeBSD 12.0-CURRENT #80 r318258: Sat May 13 22:35:16 CEST 2017 amd64, WITH_LLD_IS_LD=yes, ports tree: Revision: 440879

Trying to update lang/mono (mono-4.6.2.7_2) fails due to the following error:


[...]
libtool: link: ranlib .libs/libmini.a
libtool: link: ( cd ".libs" && rm -f "libmini.la" && ln -s "../libmini.la" "libmini.la" )
../../doltlibtool  --tag=CC   --mode=link cc -I../.. -I../../eglib/src -I../../eglib/src    -fvisibility=hidden -O2 -pipe -O3  -DLIBICONV_PLUG -fstack-protector -fno-strict-aliasing -std=gnu99 -fno-strict-aliasing -fwrapv -Wno-zero-length-array -DMONO_DLL_EXPORT -g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes  -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wno-cast-qual -Wwrite-strings -Wno-switch -Wno-switch-enum -Wno-unused-value -Wno-attributes -Qunused-arguments -Wno-unused-function -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign -Wno-return-stack-address -Wno-constant-logical-operand -Werror-implicit-function-declaration  -version-info 1:0:0   -fstack-protector -pthread -L/usr/local/lib -o libmonoboehm-2.0.la -rpath /usr/local/lib  libmini.la ../../mono/metadata/libmonoruntime.la ../../mono/io-layer/libwapi.la ../../mono/utils/libmonoutils.la -L../../eglib/src -leglib -lm  ../../libgc/libmonogc.la    -lm   -linotify -pthread
libtool: link: cc -shared  -fPIC -DPIC  -Wl,--whole-archive ./.libs/libmini.a ../../mono/metadata/.libs/libmonoruntime.a ../../mono/io-layer/.libs/libwapi.a ../../mono/utils/.libs/libmonoutils.a /usr/ports/lang/mono/work/mono-mono-4.8.1.0/eglib/src/.libs/libeglib.a ../../libgc/.libs/libmonogc.a -Wl,--no-whole-archive  -L/usr/local/lib -L../../eglib/src -lm -linotify  -O2 -O3 -fstack-protector -g -fstack-protector -pthread -pthread   -pthread -Wl,-soname -Wl,libmonoboehm-2.0.so.1 -o .libs/libmonoboehm-2.0.so.1.0.0
error: failed to compute relocation: R_X86_64_DTPOFF64
/usr/bin/ld: error: pthread_support.c:218: can't create dynamic relocation R_X86_64_TLSLD against symbol 'GC_thread_tls' defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
/usr/bin/ld: error: pthread_support.c:218: can't create dynamic relocation R_X86_64_DTPOFF32 against symbol 'GC_thread_tls' defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
/usr/bin/ld: error: pthread_support.c:354: can't create dynamic relocation R_X86_64_TLSLD against symbol 'GC_thread_tls' defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
/usr/bin/ld: error: pthread_support.c:354: can't create dynamic relocation R_X86_64_DTPOFF32 against symbol 'GC_thread_tls' defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
Comment 6 David Naylor freebsd_committer freebsd_triage 2017-05-14 18:51:05 UTC
Are you using the latest version of the ports tree, or the attached patch?  The latest version of mono is: 4.8.1.0_1
Comment 7 Ed Maste freebsd_committer freebsd_triage 2017-08-18 13:49:12 UTC
When trying to build 4.8.1.0 with WITH_LLD_IS_LD I get similar failures:

error: failed to compute relocation: R_X86_64_DTPOFF64, Invalid data was encountered while parsing the file
/usr/bin/ld: error: can't create dynamic relocation R_X86_64_TLSLD against symbol: GC_thread_tls in readonly segment
>>> defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
>>> referenced by pthread_support.c:218
>>>               pthread_support.o:(GC_init_thread_local) in archive ../../libgc/.libs/libmonogc.a

/usr/bin/ld: error: can't create dynamic relocation R_X86_64_DTPOFF32 against symbol: GC_thread_tls in readonly segment
>>> defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
>>> referenced by pthread_support.c:218
>>>               pthread_support.o:(GC_init_thread_local) in archive ../../libgc/.libs/libmonogc.a

/usr/bin/ld: error: can't create dynamic relocation R_X86_64_TLSLD against symbol: GC_thread_tls in readonly segment
>>> defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
>>> referenced by pthread_support.c:354
>>>               pthread_support.o:(GC_local_malloc) in archive ../../libgc/.libs/libmonogc.a

/usr/bin/ld: error: can't create dynamic relocation R_X86_64_DTPOFF32 against symbol: GC_thread_tls in readonly segment
>>> defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
>>> referenced by pthread_support.c:354
>>>               pthread_support.o:(GC_local_malloc) in archive ../../libgc/.libs/libmonogc.a

/usr/bin/ld: error: can't create dynamic relocation R_X86_64_TLSLD against symbol: GC_thread_tls in readonly segment
>>> defined in ../../libgc/.libs/libmonogc.a(pthread_support.o)
>>> referenced by pthread_support.c:386
>>>               pthread_support.o:(GC_local_malloc_atomic) in archive ../../libgc/.libs/libmonogc.a


As an aside, also discovered one of its dependencies seems to miss recording a build-dep:
===>  Configuring for p5-XML-Parser-2.44
env: /usr/local/bin/perl5.24.2: No such file or directory
Comment 8 Ed Maste freebsd_committer freebsd_triage 2017-08-22 20:10:12 UTC
Created attachment 185675 [details]
lang/mono: set LLD_UNSAFE
Comment 9 Ed Maste freebsd_committer freebsd_triage 2017-12-27 02:22:39 UTC
As a workaround LLD_UNSAFE was set in r457313
Comment 10 Ed Maste freebsd_committer freebsd_triage 2018-03-27 20:25:59 UTC
O. Hartmann, does this build for you now with LLD_UNSAFE?
Comment 11 O. Hartmann 2018-03-30 06:44:52 UTC
I do not have any system at the moment at hand that is installing lang/mono anymore. On poudriere, I fell back to FreeBSD's at-the-time standard for the linker and that is the legacy GNU ld. So, the problem I reported does not pop up at the moment.
Comment 12 commit-hook freebsd_committer freebsd_triage 2018-06-16 15:57:17 UTC
A commit references this bug:

Author: feld
Date: Sat Jun 16 15:56:44 UTC 2018
New revision: 472555
URL: https://svnweb.freebsd.org/changeset/ports/472555

Log:
  Update Mono to 5.10.1.47

  This brings a more modern Mono release to the ports tree. After
  discussions with others in the Mono community I targeted the mono
  5.10.1.47 release which is the latest release in the "Visual Studio"
  release channel. This is considered to be the most stable and widely
  tested, which makes it a good candidate for us. We may upgrade to 5.12
  after additional testing or introduce another Mono package for users who
  require testing against a newer release; this has yet to be determined.

  - Build from official release tarballs
  - Now include BoringSSL per upstream guidelines [1]
  - Remove ACCEPTANCE_TESTS, not being updated by upstream
  - No long require glib; Mono includes their own replacement
  - USES=display:tests required for some tests
  - Remove broken for armv6, armv7: file now available [2]
  - Mark as LLD safe as mono changed how it handles TLS [3]

  Changelog:	http://www.mono-project.com/docs/about-mono/releases/5.10.0/

  PR:		222271 [1]
  PR:		221236 [2]
  PR:		218885 [3]
  PR:		211367
  Approved by:	dbn
  Differential Revision:	https://reviews.freebsd.org/D15780

Changes:
  head/lang/mono/Makefile
  head/lang/mono/distinfo
  head/lang/mono/files/patch-configure.ac
  head/lang/mono/files/patch-eglib_src_gfile-posix.c
_U  head/lang/mono/files/patch-mcs_class_Mono.Security_Mono.Security.Cryptography_KeyPairPersistence.cs
_U  head/lang/mono/files/patch-mcs_class_Mono.Security_Mono.Security.X509_X509StoreManager.cs
_U  head/lang/mono/files/patch-mcs_tools_mono-configuration-crypto_lib_Mono.Configuration.Crypto_KeyContainerCollection.cs
_U  head/lang/mono/files/patch-mcs_tools_xbuild_data_12.0_Microsoft.CSharp.targets
_U  head/lang/mono/files/patch-mcs_tools_xbuild_data_14.0_Microsoft.CSharp.targets
  head/lang/mono/files/patch-mono_eglib_gfile-posix.c
  head/lang/mono/files/patch-mono_mini_Makefile.am.in
  head/lang/mono/files/patch-mono_mini_mini-posix.c
  head/lang/mono/files/patch-mono_mini_tramp-amd64.c
  head/lang/mono/files/patch-mono_profiler_ptestrunner.pl
  head/lang/mono/files/patch-mono_utils_mono-context.h
  head/lang/mono/files/patch-mono_utils_mono-proclib.c
  head/lang/mono/files/patch-mono_utils_mono-threads.c
  head/lang/mono/files/patch-scripts_mono-heapviz
  head/lang/mono/pkg-plist
  head/lang/mono-basic/Makefile
  head/lang/mono-basic/distinfo
  head/lang/mono-basic/files/patch-configure
  head/x11-toolkits/gtk-sharp30/Makefile
  head/x11-toolkits/gtk-sharp30/files/
  head/x11-toolkits/gtk-sharp30/files/patch-gtk_gui-thread-check_profiler_gui-thread-check.c
Comment 13 David Naylor freebsd_committer freebsd_triage 2018-06-17 19:14:58 UTC
It was my understand that LLD is the default for FreeBSD-12 now?  If that is not the case how can one test this on poudriere?
Comment 14 Ed Maste freebsd_committer freebsd_triage 2018-06-19 01:20:38 UTC
(In reply to David Naylor from comment #13)
Yes, lld is now installed as /usr/bin/ld in -current.