Bug 270768 - lang/tcl86: fails to build WITH_LLVM_BINUTILS (LLVM strip)
Summary: lang/tcl86: fails to build WITH_LLVM_BINUTILS (LLVM strip)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-tcltk (Nobody)
URL:
Keywords:
: 268064 (view as bug list)
Depends on:
Blocks: 258872
  Show dependency treegraph
 
Reported: 2023-04-11 20:02 UTC by Ed Maste
Modified: 2024-04-04 16:59 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2023-04-11 20:02:41 UTC
From the exp-run in PR258872
https://pkg-status.freebsd.org/gohan05/data/mainamd64PR258872-default/2023-04-05_14h36m44s/logs/errors/tcl86-8.6.13.log

==========
Installing libtclstub86.a to /wrkdirs/usr/ports/lang/tcl86/work/stage/usr/local/lib/
strip: error: '/wrkdirs/usr/ports/lang/tcl86/work/stage/usr/local/lib/_inst.91375_': not stripping symbol '.L.str.1' because it is named in a relocation
*** Error code 1

==========

error can be reproduced in isolation:

# strip -o /dev/null -x tclStubLib.o 
strip: error: 'tclStubLib.o': not stripping symbol '.L.str.1' because it is named in a relocation

in this case .L.str.1 is a local symbol:

# readelf -s tclStubLib.o 

Symbol table '.symtab' contains 12 entries:
   Num:    Value          Size Type    Bind   Vis       Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT   UND 
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT   ABS tclStubLib.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT     2 .text
     3: 0000000000000031     4 OBJECT  LOCAL  DEFAULT     5 .L.str.1
     4: 0000000000000000    49 OBJECT  LOCAL  DEFAULT     5 .L.str
     5: 0000000000000000   475 FUNC    GLOBAL HIDDEN      2 Tcl_InitStubs
     6: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT   UND __stack_chk_guard
     7: 0000000000000000     8 OBJECT  GLOBAL HIDDEN      4 tclStubsPtr
     8: 0000000000000008     8 OBJECT  GLOBAL HIDDEN      4 tclPlatStubsPtr
     9: 0000000000000010     8 OBJECT  GLOBAL HIDDEN      4 tclIntStubsPtr
    10: 0000000000000018     8 OBJECT  GLOBAL HIDDEN      4 tclIntPlatStubsPtr
    11: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT   UND __stack_chk_fail

tcl's build has asked to strip all non-global symbols (strip -x), but .L.str.1 is referenced by relocations:

# readelf -r tclStubLib.o | grep .L.str.1
000000000000004e  0000000300000002 R_X86_64_PC32          0000000000000031 .L.str.1 - 4
00000000000000f3  0000000300000002 R_X86_64_PC32          0000000000000031 .L.str.1 - 4
0000000000000153  0000000300000002 R_X86_64_PC32          0000000000000031 .L.str.1 - 4

Both GNU strip and ELF Tool Chain strip silently handle this case (and just retain the local symbol), but LLVM strip is stricter and emits an error upon request to strip a non-removable local symbol.

There is an LLVM ticket open for this at https://github.com/llvm/llvm-project/issues/47468. It may make sense for LLVM strip to behave the same as GNU and ELF Tool Chain strip, but I think tcl should just not use strip -x when there are symbols that cannot be stripped. My suggestion would be to just avoid stripping the .a altogether.
Comment 1 Pietro Cerutti freebsd_committer freebsd_triage 2023-04-13 14:20:28 UTC
Upstream bug report: https://core.tcl-lang.org/tcl/tktview/718de2132f487cf29dfdd0be2b90fcc0107c2aa7
Comment 2 Pietro Cerutti freebsd_committer freebsd_triage 2023-04-13 15:13:32 UTC
*** Bug 268064 has been marked as a duplicate of this bug. ***
Comment 3 Pietro Cerutti freebsd_committer freebsd_triage 2023-04-13 15:14:55 UTC
Thanks @emaste - I'm in touch with upstream. We'll see if removing -x is doable for them.
Comment 4 Ed Maste freebsd_committer freebsd_triage 2023-04-13 15:18:35 UTC
Thank you!

In the short term (or if upstream is not agreeable) we could just have tcl use GNU strip for the build, but see PR270663.
Comment 5 Ed Maste freebsd_committer freebsd_triage 2023-04-20 17:51:35 UTC
Similar issue affects x11-toolkits/tk86
Comment 6 Ed Maste freebsd_committer freebsd_triage 2023-04-24 14:47:57 UTC
For the record the upstream change was reverted, and it is unclear when a reworked fix will come. What is our appetite for carrying a local patch in the short term?
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-04-24 15:51:49 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4ef4b555f46b1bddd6600380dbcf0dacb013b95e

commit 4ef4b555f46b1bddd6600380dbcf0dacb013b95e
Author:     Pietro Cerutti <gahr@FreeBSD.org>
AuthorDate: 2023-04-24 15:49:14 +0000
Commit:     Pietro Cerutti <gahr@FreeBSD.org>
CommitDate: 2023-04-24 15:51:34 +0000

    lang/tcl8[5-7], x11-toolkits/tk8[5-7]: fix build with WITH_LLVM_BINUTILS

    PR:             270768
    Reported by:    emaste

 lang/tcl85/files/patch-Makefile.in             | 9 +++++++++
 lang/tcl86/files/patch-unix-Makefile.in        | 9 +++++++++
 lang/tcl87/files/patch-unix_Makefile.in        | 9 +++++++++
 x11-toolkits/tk85/files/patch-unix-Makefile.in | 8 ++++++--
 x11-toolkits/tk86/files/patch-Makefile.in      | 9 +++++++++
 x11-toolkits/tk87/files/patch-unix-Makefile.in | 9 +++++++++
 6 files changed, 51 insertions(+), 2 deletions(-)
Comment 8 Pietro Cerutti freebsd_committer freebsd_triage 2023-04-24 15:52:55 UTC
> What is our appetite for carrying a local patch in the short term?

Very hungry :)