Bug 230209 - lang/ocaml: fail to link with lld as /usr/bin/ld on i386
Summary: lang/ocaml: fail to link with lld as /usr/bin/ld on i386
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-30 23:50 UTC by Ed Maste
Modified: 2018-09-18 16:11 UTC (History)
2 users (show)

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


Attachments
Fixes LLD build on i386 (602 bytes, patch)
2018-09-13 11:35 UTC, Nathan
ndowens04: maintainer-approval? (michipili)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2018-07-30 23:50:43 UTC
The migration to the LLVM project's lld linker as the system linker (/usr/bin/ld) for FreeBSD is in progress - it is the case for arm64 and amd64 today, and i386 will switch once ports issues are addressed - see exp-run in PR214864.

Linking lang/ocaml with lld as /usr/bin/ld on i386 produces errors of the form:
/usr/bin/ld: error: can't create dynamic relocation R_386_32 against symbol: caml_last_return_address in readonly segment; recompile object files with -fPIC
>>> defined in roots.pic.o
>>> referenced by i386.pic.o:(.text+0x4)

http://package18.nyi.freebsd.org/data/headi386PR214864-default/2018-07-30_18h09m59s/logs/errors/ocaml-4.02.3.log
Comment 1 Nathan 2018-09-13 11:35:47 UTC
Created attachment 197068 [details]
Fixes LLD build on i386
Comment 2 Nathan 2018-09-13 11:37:00 UTC
Tested patch 12-current i386 after verifying issue and re-tested after patch to verify this fixed it
Comment 3 Ed Maste freebsd_committer freebsd_triage 2018-09-17 18:51:49 UTC
Nathan sorry I did not notice your patch before submitting review D17200 https://reviews.freebsd.org/D17200

I tried limiting the effect of the patch by setting -znotext only on i386.
Comment 4 Nathan 2018-09-17 18:55:44 UTC
(In reply to Ed Maste from comment #3)
Nah it’s fine. I should have done that as well anyway just didn’t think about it when doing these :)
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-09-18 16:05:37 UTC
A commit references this bug:

Author: emaste
Date: Tue Sep 18 16:05:15 UTC 2018
New revision: 480033
URL: https://svnweb.freebsd.org/changeset/ports/480033

Log:
  lang/ocaml: add -znotext to LDFLAGS on i386, for lld

  Example error:
  /usr/bin/ld: error: can't create dynamic relocation R_386_32 against
      symbol: caml_last_return_address in readonly segment; recompile
      object files with -fPIC

  This port links some non-PIC code, which fails with lld as it defaults
  to disallowing relocations against read-only segments.  For i386 we can
  just add -znotext unconditionally: for GNU BFD ld it just affirms BFD's
  existing default.

  PR:		214864, 230209
  Approved by:	bapt
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D17200

Changes:
  head/lang/ocaml/Makefile