mesonbuild / expat

Meson build definitions for expat
https://github.com/libexpat/libexpat
MIT License
0 stars 4 forks source link

expat 2.2.9 wrap shared lib symbol visibility issue on Linux + macOS #10

Open tp-m opened 4 years ago

tp-m commented 4 years ago

I'm getting unresolved symbols when using expat 2.2.9 as a meson subproject, and it looks like it's happening because the shared lib doesn't export any symbols. This is on Linux with gcc and macOS with clang.

To reproduce on Linux:

git clone https://gitlab.freedesktop.org/tpm/fontconfig.git
cd fontconfig
git checkout meson-rebased-fc-lang-python-port
meson --wrap-mode=forcefallback b
ninja -C b

result:

FAILED: src/libfontconfig.so.1.12.0 
cc  -o src/libfontconfig.so.1.12.0 'src/25a6634@@fontconfig@sha/fcatomic.c.o' 'src/25a6634@@fontconfig@sha/fccache.c.o' 'src/25a6634@@fontconfig@sha/fccfg.c.o' 'src/25a6634@@fontconfig@sha/fccharset.c.o' 'src/25a6634@@fontconfig@sha/fccompat.c.o' 'src/25a6634@@fontconfig@sha/fcdbg.c.o' 'src/25a6634@@fontconfig@sha/fcdefault.c.o' 'src/25a6634@@fontconfig@sha/fcdir.c.o' 'src/25a6634@@fontconfig@sha/fcformat.c.o' 'src/25a6634@@fontconfig@sha/fcfreetype.c.o' 'src/25a6634@@fontconfig@sha/fcfs.c.o' 'src/25a6634@@fontconfig@sha/fcptrlist.c.o' 'src/25a6634@@fontconfig@sha/fchash.c.o' 'src/25a6634@@fontconfig@sha/fcinit.c.o' 'src/25a6634@@fontconfig@sha/fclang.c.o' 'src/25a6634@@fontconfig@sha/fclist.c.o' 'src/25a6634@@fontconfig@sha/fcmatch.c.o' 'src/25a6634@@fontconfig@sha/fcmatrix.c.o' 'src/25a6634@@fontconfig@sha/fcname.c.o' 'src/25a6634@@fontconfig@sha/fcobjs.c.o' 'src/25a6634@@fontconfig@sha/fcpat.c.o' 'src/25a6634@@fontconfig@sha/fcrange.c.o' 'src/25a6634@@fontconfig@sha/fcserialize.c.o' 'src/25a6634@@fontconfig@sha/fcstat.c.o' 'src/25a6634@@fontconfig@sha/fcstr.c.o' 'src/25a6634@@fontconfig@sha/fcweight.c.o' 'src/25a6634@@fontconfig@sha/fcxml.c.o' 'src/25a6634@@fontconfig@sha/ftglue.c.o' -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libfontconfig.so.1 subprojects/freetype2/libfreetype.so.6.16.0 subprojects/zlib-1.2.11/libz.so subprojects/libpng-1.6.37/libpng16.so.16.37.0 subprojects/expat-2.2.9/libexpat.so.1.6.11 -lbz2 -lm -Wl,--end-group -pthread '-Wl,-rpath,$ORIGIN/../subprojects/freetype2:$ORIGIN/../subprojects/zlib-1.2.11:$ORIGIN/../subprojects/libpng-1.6.37:$ORIGIN/../subprojects/expat-2.2.9' -Wl,-rpath-link,/home/tpm/Devel/fontconfig/b/subprojects/freetype2 -Wl,-rpath-link,/home/tpm/Devel/fontconfig/b/subprojects/zlib-1.2.11 -Wl,-rpath-link,/home/tpm/Devel/fontconfig/b/subprojects/libpng-1.6.37 -Wl,-rpath-link,/home/tpm/Devel/fontconfig/b/subprojects/expat-2.2.9
/usr/bin/ld: src/25a6634@@fontconfig@sha/fcxml.c.o: in function `FcConfigMessage':
/home/tpm/Devel/fontconfig/b/../src/fcxml.c:607: undefined reference to `XML_GetCurrentLineNumber'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:610: undefined reference to `XML_GetCurrentLineNumber'
/usr/bin/ld: src/25a6634@@fontconfig@sha/fcxml.c.o: in function `FcConfigParseAndLoadFromMemoryInternal':
/home/tpm/Devel/fontconfig/b/../src/fcxml.c:3434: undefined reference to `XML_ParserCreate'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3445: undefined reference to `XML_SetUserData'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3447: undefined reference to `XML_SetDoctypeDeclHandler'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3448: undefined reference to `XML_SetElementHandler'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3449: undefined reference to `XML_SetCharacterDataHandler'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3456: undefined reference to `XML_GetBuffer'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3479: undefined reference to `XML_ParseBuffer'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3482: undefined reference to `XML_GetErrorCode'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3482: undefined reference to `XML_ErrorString'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3511: undefined reference to `XML_ParserFree'
/usr/bin/ld: /home/tpm/Devel/fontconfig/b/../src/fcxml.c:3479: undefined reference to `XML_ParseBuffer'
collect2: error: ld returned 1 exit status
tp-m commented 4 years ago

cc @dcbaker

tp-m commented 4 years ago

This is happening because by default build_tests=false and then:

  libexpat = library('expat',
    ...
    gnu_symbol_visibility : get_option('build_tests') ? 'default' : 'hidden',
  )
tp-m commented 4 years ago

This also looks dodgy:

# the lib/libexpat.def file is not valid with mingw, only with mvsc, intel-cl,
# and clang-cl
if cc.get_id() != 'gcc'

I don't think we can assume that if the compiler is not gcc that it's one of mvsc, intel-cl or clang-cl - e.g. what about "normal" clang or intel compilers?

nirbheek commented 3 years ago

This was fixed with https://github.com/mesonbuild/expat/pull/11 but then it caused https://github.com/mesonbuild/expat/issues/12, which I have a fix for.

dcbaker commented 3 years ago

The Intel complier that isn't Intel-cl is unsupported on windows by meson, and can only be used to cross compile to Linux anyway, and the def file does work with Intel-cl and clang-cl IIRC. you might be right about gnu-style clang though