Re: git: 3a01e1e1a50c - main - msun/aarch64: convert fenv functions to proper linkage

From: Konstantin Belousov <kib_at_freebsd.org>
Date: Mon, 06 Apr 2026 16:45:06 UTC
On Mon, Apr 06, 2026 at 07:25:18PM +0300, Dima Panov wrote:
> 
> 
> On 06.04.2026 19:07, Konstantin Belousov wrote:
> > On Mon, Apr 06, 2026 at 06:56:36PM +0300, Dima Panov wrote:
> > > Hello!
> > >
> > > This breaks most of libm consumers
> > >
> > > llvm/flang:
> > > ===============
> > > FAILED: [code=1] bin/flang-20
> > > : && /usr/local/libexec/ccache/c++ -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -fPIC -fno-semantic-interposition -fvisibility-inline
> > > s-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-s
> > > emi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupport
> > > ed -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion -Wcover
> > > ed-switch-default -Wno-nested-anon-types -O2 -pipe -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -DNDEBUG -Wl,--color-diagnostics -Wl,--expor
> > > t-dynamic -Wl,-z,origin -Wl,--gc-sections -Xlinker --dependency-file=tools/flang/tools/flang-driver/CMakeFiles/flang.dir/link.d tools/flang/tools/flang-driver/CMakeFiles/flang.dir/driver.cpp.o tools/
> > > flang/tools/flang-driver/CMakeFiles/flang.dir/fc1_main.cpp.o -o bin/flang-20 -L/wrkdirs/usr/ports/devel/llvm20/work-default/.build/./lib -Wl,-rpath,"\$ORIGIN/../lib:/wrkdirs/usr/ports/devel/llvm20/work-
> > > default/.build/./lib:/wrkdirs/usr/ports/devel/llvm20/work-default/.build/lib:" -lpthread lib/libflangFrontend.a lib/libflangFrontendTool.a lib/libFortranLower.a lib/libFortranSemantics.a lib/libFo
> > > rtranSupport.a lib/libflangPasses.a lib/libHLFIRTransforms.a lib/libFIRTransforms.a lib/libFIROpenACCSupport.a lib/libFlangOpenMPTransforms.a lib/libFIRCodeGen.a lib/libFIRAnalysis.a lib/libFIRB
> > > uilder.a lib/libCUFDialect.a lib/libFortranEvaluate.a lib/libFortranParser.a lib/libFortranCommon.a lib/libFortranDecimal.a lib/libFIRSupport.a lib/libHLFIRDialect.a lib/libFIRDialect.a lib/lib
> > > FIRDialectSupport.a lib/libCUFAttrs.a lib/libclang-cpp.so.20.1 lib/libMLIR.so.20.1 lib/libLLVM.so.20.1 && :
> > > ld: error: undefined symbol: feholdexcept
> >
> > This is strange. Could you show me the output of e.g.
> > readelf --dyn_syms /lib/libm.so.5 | grep feholdexcept
> > The best would be the output from the command like above for each missing
> > symbol.
> 
> missing :(
> 
> FreeBSD 16.0-CURRENT #0 main-cf1f21572897: Mon Apr 6 13:45:02 MSK 2026
> 
> root@aarch64:/ # readelf --dyn-syms /lib/libm.so.5 | grep feholdexcept
> root@aarch64:/ #
Hm, ok, perhaps I understand.
These symbols where never exported from libm, and it just happens that
they were compiled into the binaries itself due to extern inline.
So the proper fix for consumers that want the symbols is to export them
from libm.so.

> 
> full list of symbols:
> 
> Symbol table '.dynsym' contains 306 entries:

It is practically impossible to get the missed symbols from the list of
present symbols.  Try this, if there is something else missed, add the
symbols to msun/aarch64/Symbol.map.  I did not even tried to (cross-)
compile.

I will think how to get the complete list to export, meantime.
This should also be problem on any arch that provides non-standard fenv
functions.

commit 7573286180010304ca982d09ce5a980740e1e35e
Author: Konstantin Belousov <kib@FreeBSD.org>
Date:   Mon Apr 6 19:41:23 2026 +0300

    lib/msun: export arch-specific fenv methods

diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index 5112337f6297..b6e77fed5d9c 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -115,6 +115,10 @@ LIBC_ARCH=${MACHINE_CPUARCH}
 CFLAGS+=	-I${.CURDIR}/src -I${LIBC_SRCTOP}/include \
 		-I${LIBC_SRCTOP}/${LIBC_ARCH}
 SYM_MAPS+=	${.CURDIR}/Symbol.map
+ARCH_MAP=	${.CURDIR}/${LIBC_ARCH}/Symbol.map
+.if exists(${ARCH_MAP})
+SYM_MAPS+=	${ARCH_MAP}
+.endif
 
 VERSION_DEF=	${LIBC_SRCTOP}/Versions.def
 SYMBOL_MAPS=	${SYM_MAPS}
diff --git a/lib/msun/aarch64/Symbol.map b/lib/msun/aarch64/Symbol.map
new file mode 100644
index 000000000000..d24d7820ba98
--- /dev/null
+++ b/lib/msun/aarch64/Symbol.map
@@ -0,0 +1,5 @@
+FBSD_1.9 {
+	fegetenv;
+	feholdexcept;
+	feraiseexcept;
+};