From nobody Sat Jan 27 21:29:34 2024 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TMnl53ghBz58xdG for ; Sat, 27 Jan 2024 21:29:37 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TMnl53CYFz43TX; Sat, 27 Jan 2024 21:29:37 +0000 (UTC) (envelope-from dim@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706390977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZNonh0PXXApFo28DuPHDhmnklLU5iBE89ws9X/dKaPA=; b=vUwZ891IXNqjVw6+Vx/Ug8KkeFKjD7jHWNjdWM+/CA0tz7nwKG3N0H3RPYMgQXZ9Xwx/Nw JkWC0dxiyQXfksVtP9uZjJ0EiRyQAD0MOZwmG94VoSnGjOAvBQZziDQhfXE910Ea1jsTPe MSIkBQyArMoiRN2pABTXFSyZC6VABjOqQ4jMKD0rDMEKyw6jJjm+KQhCR8UIWZkHUiAh8i Cyw482fCgQcatQpjbp2hPCcVI8NFKw1qaJWHu2OGDWVxuhkrk+krdwciBjWCE5rVCYrW27 0+oMzdFe+7og3uTQRot2K4g0jm5FqpRDxBR1p/2XuswItkcfuyIMXwIgUzfZug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706390977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZNonh0PXXApFo28DuPHDhmnklLU5iBE89ws9X/dKaPA=; b=usK0XGECUvYgYSB66/gkh6Z9ObGLLRi6x8hjF5I0rpqgLF2rEVQssroyVGo2r0qPDEyJxg 4MGlwUqvKaPQSPyapjun7Na2DGe0FVKcTSzbUps3NyIPa4Thn+KSCHtW9B5/dXHQP50FW7 mVMUhmwiL+QCuEtSnufWVzEle3/wVaEe4KHB5tSsR6CtT4quvbe7fYYBmIB51kXlI1MEFH PX4tfSfR5YHJy0Ybq9j/P/ugZ1T8g8zRqsStSjDja2Wr958iq+nUFDxCn92Opj4OP0hK01 mXk3HADa0ZuPaLN87QoyEqBpJgLCONxx0/pQjIRpZXW6kqiCwuytPKzZqnXVMA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706390977; a=rsa-sha256; cv=none; b=cjEj3survT90RK7vLSyCD4IXSYAfO0kVy/H0qczJQ+fZxQOzsUIDOpcBzHo52Te3+oOMwc jmdsADqnpllF/b8dbr/qlop7C1aUEngoG30YeOH7gM5uWeluGlq0J/s+b8hZEFNLOKiZxM yUKV+k/4Id1sGl7fXe3vl2YvGPVXq4HrTPgO4ssrqfHNZWBIUQeeEhmI2MZIEGKoLTLlY0 yk0+JTdHc6outCweEXcq6h5osAFGz+vlI6cvGS8P53Dhjm/3ychje2GaObTEtPYUOPruMA sw3OtiNDLV0bAE8deAZTCBRKmI7JFa7cqbnYFuqch0X+ID7kg2pi/41SImL4OQ== Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id 4TMnl51WPwz1P8b; Sat, 27 Jan 2024 21:29:37 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (longrow.home.andric.com [192.168.0.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 15675428C2; Sat, 27 Jan 2024 22:29:35 +0100 (CET) Content-Type: text/plain; charset=us-ascii List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) Subject: Re: llvm ld vs binutils ld From: Dimitry Andric In-Reply-To: Date: Sat, 27 Jan 2024 22:29:34 +0100 Cc: FreeBSD CURRENT Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Steve Kargl X-Mailer: Apple Mail (2.3731.700.6.1.1) On 27 Jan 2024, at 18:08, Steve Kargl = wrote: >=20 > In an attempt to cleanup a bit of src/lib/msun, I ran into > a small issue that I cannot explain at the moment. If I have > /usr/bin/ld in my path prior to /usr/local/bin/ld everything > works >=20 > % which ld > /usr/bin/ld > % make clean && make cleandepend > % make >=20 > and I have a libm.so.5. But if /usr/local/bin/ld is found, I > see >=20 > % cd msun > % make clean && make cleandepend > % make > .. > ld: error: version script assignment of 'FBSD_1.0' to symbol 'fabs' \ > failed: symbol not defined > cc: error: linker command failed with exit code 1 (use -v to see = invocation) > *** Error code 1 >=20 > Stop. > make: stopped in /usr/src/lib/msun >=20 > % grep fabs /usr/src/lib/msun/Symbol.map=20 > fabs; > fabsf; > fabsl; >=20 > But, if one looks in msun/Makefile, one see >=20 > # FreeBSD's C library supplies these functions: > #COMMON_SRCS+=3D s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c >=20 > so fabs is not built with libm. =20 >=20 > % nm --dynamic /lib/libc.so.7 | grep fabs > 00000000000ba600 T fabs > % nm --dynamic /lib/libm.so.5 | grep fabs > 000000000001fa90 T fabsf > 00000000000252e0 T fabsl >=20 >=20 > Is this a known issue? Should fabs be removed from Symbol.map? Yes, fabs is excluded in msun's Makefile: # FreeBSD's C library supplies these functions: #COMMON_SRCS+=3D s_fabs.c s_frexp.c s_isnan.c s_ldexp.c s_modf.c so it should not have been in Symbol.map at all. The comment is also incorrect, since s_frexp.c and s_isnan.c *are* actually in COMMON_SRCS, see lines 79 and 80 of the Makefile. (They are indeed also in libc, so which one is chosen is only known by the linker. :) It doesn't complain with lld >=3D 16 because of https://cgit.freebsd.org/src/commit/?id=3D2ba84b4bcdd60, where it add -Wl,--undefined-version to suppress such warnings. I added that rather big hammer to be able to continue importing llvm 16, but I see now that it may be better to attempt to fix all individual failures due to missing symbols. The reason that it still goes wrong if you put /usr/local/bin in front of your PATH (or if you set LD explicitly to /usr/local/bin/ld) is that /usr/bin/cc will pick /usr/bin/ld over whatever it finds in the PATH or in the LD variable, while bsd.linker.mk still uses PATH or LD to find the linker type and version. E.g., it concludes that the linker type is BFD and the version is 2.40, then does not add the -Wl,--undefined-version to allow undefined symbols. I committed https://cgit.freebsd.org/src/commit/?id=3Dd04e03c19a8d to remove fabs from Symbol.map, and adjust the Makefile comment. -Dimitry