[Bug 270768] lang/tcl86: fails to build WITH_LLVM_BINUTILS (LLVM strip)

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 11 Apr 2023 20:02:41 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270768

            Bug ID: 270768
           Summary: lang/tcl86: fails to build WITH_LLVM_BINUTILS (LLVM
                    strip)
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: tcltk@FreeBSD.org
          Reporter: emaste@freebsd.org
            Blocks: 258872
          Assignee: tcltk@FreeBSD.org
             Flags: maintainer-feedback?(tcltk@FreeBSD.org)

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.


Referenced Bugs:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258872
[Bug 258872] [exp-run] WITH_LLVM_BINUTILS
-- 
You are receiving this mail because:
You are the assignee for the bug.