-
Notifications
You must be signed in to change notification settings - Fork 349
Windows/clang-cl: error linking static FLAC.lib #895
Description
Several functions in the FLAC library are declared like this:
https://github.com/xiph/flac/blob/master/src/libFLAC/include/private/bitwriter.h#L59
but then defined like this (note inline):
https://github.com/xiph/flac/blob/master/src/libFLAC/bitwriter.c#L357
It also has a comment at the bottom of the file:
https://github.com/xiph/flac/blob/master/src/libFLAC/bitwriter.c#L944
They are refering to the C standard that the way these functions are declared and defined is "valid".
When the library gets linked, the linker is unable to find these symbols. They get inlined and the out-of-line function bodies are not emitted.
The full bitwriter.c build rule on my setup (from ninja.build):
build src\libFLAC\CMakeFiles\FLAC.dir\bitwriter.c.obj: C_COMPILER__FLAC_unscanned_Release D$:\modding\nlc\engine\reaper-engine\3rd_party\Src\Xiph\flac\flac\src\libFLAC\bitwriter.c || cmake_object_order_depends_target_FLAC
CONFIG = Release
DEFINES = -DFLAC__NO_DLL -DHAVE_CONFIG_H -D_CRT_SECURE_NO_WARNINGS -D_DARWIN_C_SOURCE -D_POSIX_PTHREAD_SEMANTICS -D_TANDEM_SOURCE -D_USE_MATH_DEFINES -D__STDC_WANT_IEC_60559_BFP_EXT__ -D__STDC_WANT_IEC_60559_DFP_EXT__ -D__STDC_WANT_IEC_60559_FUNCS_EXT__ -D__STDC_WANT_IEC_60559_TYPES_EXT__ -D__STDC_WANT_LIB_EXT2__ -D__STDC_WANT_MATH_SPEC_FUNCS__
FLAGS = -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Winline /DWIN32 /D_WINDOWS /O2 /Ob2 /Oi /Ot /Oy /DNDEBUG -DNDEBUG /O2 /Ob2 /DNDEBUG /MP /O2 /Ob2 /Oi /Oy /Ot /GL /Gy /Gw /W4 /GF /GS /Zi /GT /Brepro /bigobj /permissive- /volatile:iso /Zc:inline /Zc:preprocessor /Zc:enumTypes /Zc:lambda /Zc:__STDC__ /Zc:__cplusplus /Zc:externConstexpr /Zc:throwingNew /Zc:checkGwOdr /Zc:templateScope /DNOMINMAX -fno-delayed-template-parsing -fstrict-aliasing /D_CRT_STDIO_ISO_WIDE_SPECIFIERS -fno-ms-compatibility -fgnuc-version=0 /utf-8 -DS_IWRITE=_S_IWRITE -Dfileno=_fileno -Dgetenv=getenv -Doff_t=_off_t -Dstrdup=_strdup -Dutimbuf=_utimbuf -march=skylake -mavx2 -mvpclmulqdq /FIintrin.h -flto -fmerge-all-constants -fforce-emit-vtables -fwhole-program-vtables /clang:-fcoro-aligned-allocation /clang:-fopenmp -Wextra -Wmost -Wno-error=unused-command-line-argument -Werror=format -Wformat-nonliteral -Werror=format-pedantic -Werror=format-signedness -Werror=format-type-confusion -Werror=microsoft -Werror=move -Werror=nan-infinity-disabled -Werror=parentheses -Werror=strict-aliasing -Werror=tautological-compare -Werror=typename-missing -Werror=weak-vtables /D_WIN32_WINNT=0x0A00 /DWINVER=0x0A00 /D_MSVC_STL_HARDENING=1 /DNDEBUG /D_ITERATOR_DEBUG_LEVEL=0 -clang:-std=c23 -MD /fp:fast /wd4267 /wd4996 -Wdeclaration-after-statement
INCLUDES = -ID:\modding\nlc\engine\reaper-engine\3rd_party\Src\Xiph\flac\flac\include -ID:\modding\nlc\engine\reaper-engine\3rd_party\Src\Xiph\flac\_Build -ID:\modding\nlc\engine\reaper-engine\3rd_party\Src\Xiph\flac\flac\src\libFLAC\include -imsvcD:\modding\nlc\engine\reaper-engine\3rd_party\Src\Xiph\ogg\_Build\Release\x64\include
I don't see anything illegal here. All other libraries and my whole project compile and work.
I tried adding -fgnu89-inline and defining inline as inline __attirubte__((__gnu_inline__)), but the symbols still don't get emitted.
To me it looks like incorrectly written library code. On the other hand, I don't see any similar issue reports here.
So first of all, I'd like to understand whether it's a compiler problem or a library problem. I've filed the same issue to the LLVM repo to be completely fair: llvm/llvm-project#187759