Tcl Source Code

View Ticket
Login
EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA
Ticket UUID: 718de2132f487cf29dfdd0be2b90fcc0107c2aa7
Title: review use of strip on the stubs library
Type: Bug Version: 8.6
Submitter: gahr Created on: 2023-04-13 14:19:33
Subsystem: 53. Configuration and Build Tools Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2023-04-26 09:29:50
Resolution: None Closed By: nobody
    Closed on:
Description:
Over at FreeBSD, I got a bug report regarding Tcl (8.6) not building using the LLVM linker: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270768.

TL;DR

INSTALL_STRIP_LIBRARY uses strip -x (https://core.tcl-lang.org/tcl/file?ci=3a6e95a25219a787&name=unix/Makefile.in&ln=154), which means we want to strip all non-global symbols, 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

Is -x correct? Can we do without it?
User Comments: gahr added on 2023-04-26 09:29:50:
I build and installed the current trunk [969b05] with and without -x.

libtcl9.0.so is 1.9M with -x and 2.0M without. The static libraries don't change. Perhaps can we get rid of -x altogether?

gahr (claiming to be gaht) added on 2023-04-24 19:57:15:
Meanwhile, I patched the Tcl/Tk ports on FreeBSD:
https://cgit.freebsd.org/ports/commit/?id=4ef4b555f46b1bddd6600380dbcf0dacb013b95e

emaste added on 2023-04-24 16:53:23:
One other note - there were only two significant ports in the FreeBSD ports collection with this issue, TCL and PostgreSQL.

PostgreSQL is now fixed, with the change here:
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=a14afd3bdc21c0c56401fb8cb2fce74f4b7dc446

They changed -x to --strip-unneeded, but they were already using --strip-uneeded on shared libraries. This is only in the case that strip's -V output includes "GNU strip", so that's how they avoided running into this on Darwin etc.

LLVM's strip includes "GNU strip" in its version string:
# strip -V
llvm-strip, compatible with GNU strip
LLVM (http://llvm.org/):
  LLVM version 15.0.7
  Optimized build with assertions.
  Default target: x86_64-unknown-freebsd14.0
  Host CPU: znver2

There seems to be no consensus on stripping .a archives, so it would be good to understand why the strip is there in the first place in order to find the best path forward.

emaste added on 2023-04-24 12:39:40:
Another option is to just avoid stripping the .a altogether.

pooryorick added on 2023-04-24 11:29:00:

Since the commit wasn't accepted the solution is going to have to be modification of tcl.m4, configure.ac, and Makefile.in to enable automatic selection of the proper options at build time.


pooryorick added on 2023-04-24 11:11:23:
I'm unassigning myself from this ticket for now in the hope that someone else will get to this earlier than I can.

gahr added on 2023-04-24 10:32:34:
So this was reverted in 82baf7827f1412fa. What's the solution going to be?

pooryorick added on 2023-04-14 11:53:24:

"--strip-unneeded" seems to be the right option to provide. Fixed for core-8-6-branch in [ecb8e87a60], for core-8-branch in [39514b5729], and for trunk in [af4865b183].


gahr added on 2023-04-13 18:20:48:
oops sure, I don’t know where the word linker came from.. probably too many context switches on my side :) thanks!

emaste added on 2023-04-13 16:09:04:
One small clarification: it is LLVM's strip (aka llvm-readobj) that causes the issue, not the linker. LLVM strip is more strict than GNU strip and ELF Tool Chain strip, both of which silently keep the symbols referenced by relocations.

In the FreeBSD experimental ports build using LLVM tools tcl and postgresql are the only significant ports that failed to build due to this issue.