You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Undefined scalbnf after switching to new emsdk 3.1.42 #19781
Hello,
Today I switched to new emsdk 3.1.42 and unfortunatelly my project failed to compile now.
It throws error during linking:
wasm-ld: error: C:\Projects\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc.a(scalbnf.o): undefined symbol: scalbnf
The problem is i don't use any scalbnf in my project explicitly. But I'm using SDL2. And seems like SDL2 is using this function:
changed the title [-]Undefined sclbnf after switching to new emsdk 3.1.42[/-][+]Undefined scalbnf after switching to new emsdk 3.1.42[/+]on Jul 5, 2023
Seems likely to be related to #16836 (comment).. although the error message you are seeing here is very confusing since the scalbnf.o object file contains just one symbol definition which is scalbnf.. so I can't see how this error would ever be possible.
Without lto the project compiled fine with emsdk 3.1.42
And though non-lto wasm file is less in size that the lto version - i still need lto to optimize the code beweeen obj files / libs.
With -flto i have this observations:
emsdk 3.1.41 generates libc.a of size: 6050348 bytes.
emsdk 3.1.42 compiles libc.a of size 6042782 bytes.
As i mentioned earlier 3.1.41 links my project fine.
3.1.42 - fails.
My project is quite huge, so i cannot share it. Also i don't have much time for more deep investigations and creating small test cases.
Probably later, if the issue will remain in future emsdk versions...
Tried to use sdk 3.1.44, the same error:
undefined symbol: scalbnf.
I even tried workaround in my code:
// Workaround for emsdk: 3.1.44
float __cdecl scalbnf(float x, int n)
{
union { float f; uint32_t i; } u;
float_t y = x;
if (n > 127)
{
y *= 0x1p127f;
n -= 127;
if (n > 127)
{
y *= 0x1p127f;
n -= 127;
if (n > 127)
n = 127;
}
}
else
if (n < -126)
{
y *= 0x1p-126f * 0x1p24f;
n += 126 - 24;
if (n < -126)
{
y *= 0x1p-126f * 0x1p24f;
n += 126 - 24;
if (n < -126)
n = -126;
}
}
u.i = (uint32_t)(0x7f + n) << 23;
x = y * u.f;
return x;
}
And now it reports the same error in my code.
Looks like it treats scalbnf symbol as reserved and doesn't allow to declare the function with this name.
Probably there is some define with this name exists. But i didn't find it.
Speaking of bisection, I tried to reproduce with the STR from the last comment, but @akien-mga I don't see an error on 3.1.42:
That's because I already merged a workaround for this issue: godotengine/godot#81340
I should have pinned a specific commit in my steps to reproduce, I'll amend them.
$ git bisect bad
dcada612a092d69dac9d5c8a1930198b78d98216 is the first bad commit
commit dcada612a092d69dac9d5c8a1930198b78d98216
Author: chromium-autoroll <chromium-autoroll@skia-public.iam.gserviceaccount.com>
Date: Wed Jun 7 17:52:37 2023 +0000
Roll llvm-project from e387f49d133d to 5f6f8a8e255d (127 revisions)
https://chromium.googlesource.com/external/github.com/llvm/llvm-project.git/+log/e387f49d133d..5f6f8a8e255d
2023-06-07 dschuff@chromium.org [WebAssembly] Add ldexp{,f,l} libcall signatures
2023-06-07 leandro.lupori@linaro.org [InstrProf] Skip Balanced Partitioning tests on ARM
2023-06-07 caleb.zulawski@gmail.com Improve WebAssembly vector bitmask, mask reduction, and extending
2023-06-07 alangford@apple.com [lldb][NFCI] Change type of Broadcaster's name
2023-06-07 rikhuijzer@pm.me [MLIR][Tosa] Fix fp canonicalization for `clamp`
2023-06-07 rikhuijzer@pm.me [mlir][quant] Move comments to TableGen statements
2023-06-07 maksim.levental@gmail.com [MLIR][python bindings] TypeCasters for Attributes
2023-06-07 jay.foad@amd.com [AMDGPU] Regenerate some spill checks
2023-06-07 massberg@google.com Fix parameter name in Sema::addInitCapture to ByRef.
2023-06-07 koraq@xs4all.nl [LLVM] Removes CMake work-arounds.
2023-06-07 thakis@chromium.org [gn] port 66a562d22e7 more (libc++ _LIBCPP_HAS_NO_FILESYSTEM)
2023-06-07 aaron@aaronballman.com Add support for the NO_COLOR environment variable
2023-06-07 craig.topper@sifive.com [RISCV] Use inheritance to reduce repeated code in RISCVInstrInfoV.td. NFC
2023-06-07 koraq@xs4all.nl [MLIR] Removes CMake work-arounds.
2023-06-07 koraq@xs4all.nl [compiler-rt] Removes CMake work-arounds.
2023-06-07 thakis@chromium.org [gn] port 66a562d22e7 (libc++ _LIBCPP_HAS_NO_FILESYSTEM)
2023-06-07 tom.eccles@arm.com Revert "[flang][hlfir] allow recursive intrinsic lowering"
2023-06-07 kpdev42@gmail.com [TableGen] Emit separate computeRequiredFeatures() function
2023-06-07 i@maskray.me [Option] Support special argument "--"
2023-06-07 ldionne.2@gmail.com [libc++] Roll up fstream support into filesystem support
2023-06-07 desk@justincady.com [ASAN] Fix validation size for dirent on FreeBSD
2023-06-07 timo.stripf@emmtrix.com [clang][DeclPrinter] Fix AST print of out-of-line record definitions
2023-06-07 kbessonova@accesssoftek.com [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)
2023-06-07 tom.eccles@arm.com [flang][hlfir] allow recursive intrinsic lowering
2023-06-07 tom.eccles@arm.com [flang][hlfir] relax the strictness of intrinsic verifiers
2023-06-07 thakis@chromium.org [gn] port 1794532bb94
2023-06-07 thakis@chromium.org [gn] port d19a3834dce5
2023-06-07 zhongyunde@huawei.com [LV] Add option to tune the cost model, NFC
2023-06-07 vyng@google.com Reland "D144999 [MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs."
2023-06-07 npopov@redhat.com [Clang] Convert some tests to opaque pointers (NFC)
2023-06-07 pierre.vanhoutryve@amd.com [clang][CodeGen] Fix GPU-specific attributes being dropped by bitcode linking
2023-06-07 michael.hliao@gmail.com [TableGen] Add !setdagarg and !setdagname
2023-06-07 phoebe.wang@intel.com [X86][FP16] Do not generate VBROADCAST for fp16
2023-06-07 Matthew.Arsenault@amd.com PreISelIntrinsicLowering: Identify load.relative with intrinsic id
2023-06-07 Matthew.Arsenault@amd.com AMDGPU: Add MF independent version of getImplicitParameterOffset
2023-06-07 Matthew.Arsenault@amd.com AMDGPU: Use available subtarget member
2023-06-07 jiefu@tencent.com [Clang][OpenMP] Fix -Wcovered-switch-default in CGOpenMPRuntime.cpp (NFC)
2023-06-07 david.green@arm.com [AArch64][SVE] Add a commutative VSelectCommPredOrPassthruPatFrags
2023-06-07 Andrew.Gozillon@amd.com [Clang][OpenMP][IRBuilder] Move registerTargetGlobalVariable & getAddrOfDeclareTargetVar into the OMPIRBuilder
2023-06-07 martin@martin.st [compiler-rt] Do not redefine builtins in MinGW configs either
2023-06-07 jacob.crawley@arm.com [flang][hlfir] Add hlfir.dot_product intrinsic
2023-06-07 jhuber6@vols.utk.edu [libc] Silence warning about returning from noreturn function
2023-06-07 elver@google.com [sanitizer_common] Use interception macros for s390 __tls_get_addr declarations
2023-06-07 massberg@google.com [clang] Show error if defaulted comparions operator function is volatile or has ref-qualifier &&.
2023-06-07 ivan.kosarev@amd.com [AMDGPU][NFC] Add a getRegBitWidth() helper for TargetRegisterClass operands.
2023-06-07 christian.kandeler@qt.io [clangd] Add semantic token for labels
2023-06-07 serguei.katkov@azul.com [CGP] Add test to show the missed case in remove llvm.assume
2023-06-07 me@m-sp.org [mlir][transform] Add builder to ApplyPatternsOp
2023-06-07 valery.pykhtin@gmail.com [AMDGPU] Turn off pass to rewrite partially used virtual superregisters after RenameIndependentSubregs pass with registers of minimal size.
2023-06-07 llvm-dev@redking.me.uk [X86] Add test case for Issue #63108
2023-06-07 hokein.wu@gmail.com [include-cleaner] Report all specializations if the primary template is introduced by a using-decl.
2023-06-07 me@m-sp.org [mlir][vector][transform] Add ApplyCastAwayVectorLeadingOneDimPatternsOp
2023-06-07 corentinjabot@gmail.com [clang] Fix assertion while parsing an invalid for loop
2023-06-07 elver@google.com Revert "[compiler-rt] Allow 3 simultaneous interceptors on Linux"
2023-06-07 juamarti@amd.com [AsmPrinter][AMDGPU] Generate uwtable entries in .eh_frame
2023-06-07 pierre.vanhoutryve@amd.com [NFC][RFC][TableGen] Split GlobalISelEmitter.cpp
2023-06-07 agrossman154@yahoo.com [CMake] Add option to link LLVM/subproject executables against LLVM libc
2023-06-07 elver@google.com Fix "[compiler-rt] Allow 3 simultaneous interceptors on Linux"
2023-06-07 elver@google.com [compiler-rt] Allow 3 simultaneous interceptors on Linux
2023-06-07 me@m-sp.org [mlir][linalg] Add option to pad Linalg ops to a specified multiple
2023-06-07 me@m-sp.org [mlir][linalg][NFC] Simplify padOperandToSmallestStaticBoundingBox
2023-06-07 luxufan@iscas.ac.cn [LoopIdiom] Freeze BitPos if !isGuaranteedNotToBeUndefOrPoison
2023-06-07 bing1.yu@intel.com [CodeGen] Disable default copy assignment operator for struct VectorInfo
2023-06-07 bing1.yu@intel.com [CodeGen] Disable default copy ctor and copy assignment operator for class Array
2023-06-07 bing1.yu@intel.com [CodeGen] Disable default copy ctor and copy assignment operator for VLIWPacketizerList
2023-06-07 bing1.yu@intel.com [CodeGen] Disable default copy ctor and copy assignment operator for class Scoreboard
2023-06-07 bing1.yu@intel.com [CodeGen] Disable default copy ctor and copy assignment operator for InterferenceCache
2023-06-07 bing1.yu@intel.com [CodeGen] Disable default copy ctor and copy assignment operator for class Circuits
2023-06-07 bing1.yu@intel.com [CodeGen] Disable default copy ctor and copy assignment operator for VLIWResourceModel
2023-06-07 craig.topper@sifive.com [RISCV] Fix sched class for MC layer version of vmsgt.vx.
2023-06-07 wenju.he@intel.com Set isRequired true for CFGViewer/CFGPrinter passes
2023-06-07 craig.topper@sifive.com [RISCV] Fix sched class for MC layer version of vrsub.vx.
2023-06-07 luweining@loongson.cn [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`
2023-06-07 craig.topper@sifive.com [RISCV] Split scheduler classes for vector min/max from compares.
2023-06-07 lntue@google.com [libc] Fix undefined behavior of left shifting signed integer in exp2f.cpp.
2023-06-07 michael.platings@arm.com [NFC][Driver] Change Multilib flag representation
2023-06-07 michael.platings@arm.com [NFC][Driver] Change MultilibBuilder interface
2023-06-07 cao.joshua@yahoo.com [ValueTracking] Implied conditions for lshr
2023-06-07 cao.joshua@yahoo.com [InstSimplify] Add tests for shl implied conditions
2023-06-07 i@maskray.me [M68k,MSP430,VE,Xtensa] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC
2023-06-07 szakharin@nvidia.com [flang][hlfir] Enable assignments with allocatable components.
2023-06-07 i@maskray.me [Hexagon,Lanai,LoongArch,Sparc] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC
2023-06-07 git@xen0n.name [LoongArch] Define the LAELF v20230519 relocs
2023-06-07 yedeng.yd@linux.alibaba.com [LICM] [Coroutines] Don't hoist threadlocals within presplit coroutines
2023-06-07 Jeffrey.Byrnes@amd.com [AMDGPU][IGLP]: Add rules to SchedGroups
2023-06-07 llvmgnsyncbot@gmail.com [gn build] Port 1794532bb942
2023-06-07 ellis.sparky.hoag@gmail.com [InstrProf] Move BPFunctionNode test to ProfileDataTests
2023-06-07 yedeng.yd@linux.alibaba.com [Coroutines] [LICM] Precommit test for D151774
2023-06-07 craig.topper@sifive.com [RISCV] Remove overly restrictive assert from negateFMAOpcode.
2023-06-07 jim@andestech.com [NFC] Remove unneeded semicolon after function definition
2023-06-07 craig.topper@sifive.com [RISCV] Fix UBSan failure on signed integer overflow.
2023-06-07 paulkirth@google.com Revert "[TypePromotion] Don't treat bitcast as a Source"
2023-06-07 llvmgnsyncbot@gmail.com [gn build] Port 44268271f61e
2023-06-07 ismail@bennani.ma [lldb/test] Fix target-label.test on Fuchsia
2023-06-07 fmayer@google.com Revert "Revert "[RISCV] Add special case to selectImm for constants that can be created with (ADD (SLLI C, 32), C).""
2023-06-07 fmayer@google.com Revert "[RISCV] Add special case to selectImm for constants that can be created with (ADD (SLLI C, 32), C)."
2023-06-07 fmayer@google.com Revert "[Sanitizers] Remove BuildId from sanitizers stacktrace on
2023-06-07 marcone@google.com [scudo] Enable MTE in Trusty
2023-06-06 thakis@chromium.org [gn build] Port 1117b9a284aa
2023-06-06 u_hameed@apple.com [Sanitizers] Remove BuildId from sanitizers stacktrace on Darwin
2023-06-06 haowei@google.com [Fuchsia] Add llvm-strings to Fuchsia clang build.
2023-06-06 kunww@google.com [mlir][sparse][gpu] add sm8.0+ tensor core 2:4 sparsity support
2023-06-06 ismail@bennani.ma [lldb] Disable some tests on windows
2023-06-06 aeubanks@google.com Revert "Reland [compiler-rt][CMake] Properly set COMPILER_RT_HAS_LLD"
2023-06-06 aaupov@fb.com [BOLT][NFC] Fix debug messages
2023-06-06 jonas@devlieghere.com [lldb] Fix "NameError: name 'self' is not defined" when using crashlog -c
2023-06-06 i@maskray.me [Driver] Change some Separate CC1 options to use the Joined = form
2023-06-06 Matthew.Arsenault@amd.com clang/HIP: Inline frexp/frexpf implementations
2023-06-06 aaron@aaronballman.com Fix LLVM Sphinx build; NFC
2023-06-06 craig.topper@sifive.com [RISCV] Use const reference when looping over RISCVMatInt::InstSeq. NFC
2023-06-06 tra@google.com [NVPTX] Adapt tests to make them usable with CUDA-12.x
2023-06-06 Matthew.Arsenault@amd.com LangRef: Try to fix sphinx bot error
2023-06-06 Matthew.Arsenault@amd.com ValueTracking: Add baseline test for ldexp computeKnownFPClass
2023-06-06 i@maskray.me [test] Restore x86-registered-target in Driver/as-warnings.c
2023-06-06 Matthew.Arsenault@amd.com clang: Start emitting intrinsic for __builtin_ldexp*
2023-06-06 Matthew.Arsenault@amd.com IR: Add llvm.ldexp and llvm.experimental.constrained.ldexp intrinsics
2023-06-06 Matthew.Arsenault@amd.com AMDGPU/GlobalISel: Fix broken / copy paste error in sext_inreg test
2023-06-06 nikolasklauser@berlin.de [libc++] Refactor __less
2023-06-06 i@maskray.me [Driver] Change some Separate CC1 options to use the Joined = form
2023-06-06 aaupov@fb.com [profi][NFC] Get rid of afdo_detail::TypeMap
2023-06-06 benny.kra@googlemail.com [bazel] Port 44268271f61e46636619623d52013c3be3e272c0
2023-06-06 benny.kra@googlemail.com [bazel] Port 1117b9a284aa6e4b1f3cbde31825605bd07a2384
2023-06-06 ldionne.2@gmail.com [libc++] Disable int128_t and ship filesystem on MSVC by default
2023-06-06 craig.topper@sifive.com [RISCV] Use PACK in RISCVMatInt for constants that have the same lower and upper 32 bits.
2023-06-06 ldionne.2@gmail.com [libc++] Use Lit annotations for all .gen.py tests
2023-06-06 craig.topper@sifive.com [RISCV] Add early out to generateInstSeq when the initial sequence is 1 or 2 instructions.
2023-06-06 aeubanks@google.com [NFC][lld][COFF] Rename findFile* methods
Unfortunately a pretty long list landed there. I can bisect into that range, but @sbc100 I see you have a PR open already so maybe you know the cause of the regression already?
Which looked way more likely to actually get called, and indeed the stb_image and stb_vorbis libraries (which were the only two failing in my case) are using it. Same process could be possibly used for htons etc., although I didn't find anything immediately obvious when searching for them now.
Not sure what exactly LTO does that it doesn't see the dependency between the functions.
Activity
[-]Undefined sclbnf after switching to new emsdk 3.1.42[/-][+]Undefined scalbnf after switching to new emsdk 3.1.42[/+]sbc100 commentedon Jul 5, 2023
My guess is that this actually broke in 3.1.41, and that the change that did it was the update of libc++/lib++abi in #19515.
Can you confirm that 3.1.41 is also broken for you?
sbc100 commentedon Jul 5, 2023
Also, can you confirm if this is an LTO-specific issue? i.e. does it also happen when you build without
-flto?Honya2000 commentedon Jul 5, 2023
Actually checked out to 3.1.41 and this fixed the issue.
Will try without lto…
Add some testing of scalbn{f,l} builtin math function. NFC
sbc100 commentedon Jul 5, 2023
I'm trying to repro this locally and not having much luck. I've added some testing here: #19782
sbc100 commentedon Jul 5, 2023
Seems likely to be related to #16836 (comment).. although the error message you are seeing here is very confusing since the
scalbnf.oobject file contains just one symbol definition which isscalbnf.. so I can't see how this error would ever be possible.sbc100 commentedon Jul 5, 2023
See also #19774
Add some testing of scalbn{f,l} builtin math function. NFC (#19782)
Honya2000 commentedon Jul 6, 2023
Without lto the project compiled fine with emsdk 3.1.42
And though non-lto wasm file is less in size that the lto version - i still need lto to optimize the code beweeen obj files / libs.
With -flto i have this observations:
emsdk 3.1.41 generates libc.a of size: 6050348 bytes.
emsdk 3.1.42 compiles libc.a of size 6042782 bytes.
As i mentioned earlier 3.1.41 links my project fine.
3.1.42 - fails.
I'm using this options to compile:
set(CMAKE_CXX_FLAGS "-flto -frtti -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=1 -DNDEBUG -s ALLOW_MEMORY_GROWTH=1 -s USE_SDL=2 --bind")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --bind -flto -s WASM=1 -O3 -s EXPORT_NAME=Module -s ALLOW_MEMORY_GROWTH=1 -fexceptions -frtti -s USE_SDL=2 -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2 -s USE_WEBGL2=1 -s AUTO_NATIVE_LIBRARIES=1 -s AUTO_JS_LIBRARIES=1 -s REVERSE_DEPS=all -s ENVIRONMENT=web")
My project is quite huge, so i cannot share it. Also i don't have much time for more deep investigations and creating small test cases.
Probably later, if the issue will remain in future emsdk versions...
For now I have to stick to 3.1.41.
sbc100 commentedon Jul 6, 2023
Since you have a repro case, if you get time to look at this again, a useful task would be to try to try down which change in the 3.1.42 -> 3.1.42 range caused this issue. There are instructions for how to bisect on emsdk versions here: https://emscripten.org/docs/contributing/developers_guide.html#bisecting
CI: switch back to emsdk version 3.1.40
Honya2000 commentedon Aug 17, 2023
Tried to use sdk 3.1.44, the same error:
undefined symbol: scalbnf.
I even tried workaround in my code:
And now it reports the same error in my code.
Looks like it treats scalbnf symbol as reserved and doesn't allow to declare the function with this name.
Probably there is some define with this name exists. But i didn't find it.
Honya2000 commentedon Aug 17, 2023
tried to replace all scalbnf symbols to _scalbnf inside headers and sources of emsdk/upstream.
This didn't fix the issue:
wasm-ld: error: C:\Projects\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc.a(scalbnf.o): undefined symbol: _scalbnf
Honya2000 commentedon Aug 17, 2023
i give up.
Will have to rollback to 3.1.41 again.
19 remaining items
sbc100 commentedon Sep 7, 2023
I'm also struggling to reproduce this. I tried the code produced by @Honya2000 in #19781 (comment) but I can't get it to fail.
Does anyone have a simple repro case?
akien-mga commentedon Sep 8, 2023
That's because I already merged a workaround for this issue: godotengine/godot#81340
I should have pinned a specific commit in my steps to reproduce, I'll amend them.
mosra commentedon Sep 8, 2023
Simple repro case is below. Fails for me with 3.1.44, removing
-fltomakes it pass:Exclude scalbnf.c from LTO
kripken commentedon Sep 8, 2023
Thanks @mosra !
I bisected with that to this:
Unfortunately a pretty long list landed there. I can bisect into that range, but @sbc100 I see you have a PR open already so maybe you know the cause of the regression already?
akien-mga commentedon Sep 8, 2023
You've got 4 commits directly related to
ldexpin that batch:Exclude scalbnf.c from LTO
Exclude scalbnf.c from LTO
Exclude scalbnf.c from LTO (#20215)
kripken commentedon Sep 8, 2023
(For anyone like me confused by the connection between
scalbnfandldexp, it seems that "On binary systems (where FLT_RADIX is 2), scalbn is equivalent to ldexp").mosra commentedon Sep 9, 2023
Just to give more context on how I found that myself -- after seeing that none of the code on my end called
scalbnfdirectly, I went looking forscalbnfinside musl, and found thatldexp()uses it: https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/math/ldexpf.cWhich looked way more likely to actually get called, and indeed the
stb_imageandstb_vorbislibraries (which were the only two failing in my case) are using it. Same process could be possibly used forhtonsetc., although I didn't find anything immediately obvious when searching for them now.Not sure what exactly LTO does that it doesn't see the dependency between the functions.
huangy10 commentedon Jul 11, 2024
This problem can be solved by adding
-Wl,-u,scalbnlto the linker flags.Read this: #16836
justinzhuguangwen commentedon Nov 27, 2024
Thanks, adding
-Wl,-u,scalbnlto the linker flags worked perfectly!Fix Emscripten 3.1.42+ LTO linker errors related to scalbnf().