Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] AutoToolsBuildEnvironment: add -stdlib in LDFLAGS if clang? #7109

Closed
1 task done
SpaceIm opened this issue May 27, 2020 · 2 comments
Closed
1 task done
Assignees

Comments

@SpaceIm
Copy link
Contributor

SpaceIm commented May 27, 2020

With AutoToolsBuildEnvironment, I've noticed that -stdlib=libc++ was missing in LDFLAGS while trying to make GDAL recipe works in CCI.
Therefore, GDAL fails to build executables if clang and libc++ on Linux (and shared lib build thanks to some dependencies passing -lc++ (C++ lib with C API) in LIB I think).
As a workaround, I've added CXXFLAGS to link commands creating executables in GDAL.

Shouldn't AutoToolsBuildEnvironment add -stdlib in LDFLAGS env var?

@SpaceIm SpaceIm changed the title [question] AutoToolsBuildEnvironment: -stdlib to LDFLAGS? [question] AutoToolsBuildEnvironment: add -stdlib in LDFLAGS? May 27, 2020
@SpaceIm SpaceIm changed the title [question] AutoToolsBuildEnvironment: add -stdlib in LDFLAGS? [question] AutoToolsBuildEnvironment: add -stdlib in LDFLAGS if clang? May 27, 2020
@jgsogo
Copy link
Contributor

jgsogo commented May 28, 2020

I think this is something for the recipe, isn't it? It is something needed only for C++ libraries with a C API or for C libraries linking to C++ ones. IMO it is is something that only the recipe knows as it depends on the library being packaged and/or required.

Probably I'm missing something so I'd more details.

Thanks!

@jgsogo jgsogo self-assigned this May 28, 2020
@SpaceIm
Copy link
Contributor Author

SpaceIm commented May 28, 2020

I think this is something for the recipe, isn't it? It is something needed only for C++ libraries with a C API or for C libraries linking to C++ ones

No, I shouldn't have talk about C++ libraries with C API. GDAL has a complex dependency tree but it's unrelated. It's just that, as a lucky side effect of some dependencies propagating -lc++ (thanks to a trick used in the recipe of those dependencies), the issue I describe did not occur while creating the shared lib of GDAL, but afterward when it tries to create GDAL's executables, because -stdlib=libc++ is missing in link command line.

Probably I'm missing something so I'd more details.

What I mean is that using clang with libc++ on Linux seems to require -stdlib=libc++ both in compile AND link command line, therefore AutoToolsBuildEnvironment should probably populate LDFLAGS accordingly.

For example, here are commands for building one executable of gdal:

Compilation:

/bin/bash /tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/libtool --mode=compile --silent --tag=CXX clang++ -std=c++11 -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/port -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/gcore -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/alg -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/ogr -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/ogr/ogrsf_frmts -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/gnm -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/apps -DHAVE_SSE_AT_COMPILE_TIME -m64 -fPIC -stdlib=libc++  -g -DDEBUG -ftrapv -fvisibility=hidden  -Wall -Wextra -Winit-self -Wunused-parameter -Wformat -Werror=format-security -Wno-format-nonliteral -Wshorten-64-to-32 -Wshadow -Werror=vla -Wdate-time -Wnull-dereference -Wextra-semi -Wcomma -Wfloat-conversion -Wdocumentation -Wno-documentation-deprecated-sync -Wunused-private-field -Wmissing-declarations -Wnon-virtual-dtor -Woverloaded-virtual -fno-operator-names -Wzero-as-null-pointer-constant -Wimplicit-fallthrough  -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/frmts/vrt -DGNM_ENABLED -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/json-c/0.13.1/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libgeotiff/1.6.0/_/_/package/a9fbdb19bebdff8d60cc4f20198ff2e86ea26a06/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/flatbuffers/1.12.0/_/_/package/ab1732eaa9b018f8ce55e42c1863eee4f20db10b/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libiconv/1.16/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libpng/1.6.37/_/_/package/a5db9977b995c3a52f6068c4befeb555e2aa78ee/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/giflib/5.1.4/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/geos/3.8.1/_/_/package/819c37cee2f8127f8ac8b5386c4ba4a3c58e0afb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/proj/7.0.0/_/_/package/9e8e2da8da6517b3d18441049c73f8deeec5224e/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libtiff/4.1.0/_/_/package/4cfb872a7d959dfb53da0abead498a7ffe3cbe72/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/sqlite3/3.31.1/_/_/package/8726bdb7fed1c9d10784d2490c79f6b14c4fe44d/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libcurl/7.69.1/_/_/package/32b2c6d4da512dd3d22600a1021c80fca6ac4095/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/zlib/1.2.11/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/xz_utils/5.2.4/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libjpeg/9d/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/jbig/20160605/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/zstd/1.4.3/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libwebp/1.0.3/_/_/package/6a842bb5bec37e0c6199fd57aedd95fdcc7cbc98/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/openssl/1.1.1g/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -DLIBJPEG_STATIC -DLZMA_API_STATIC -DCURL_STATICLIB=1 -DGEOS_INLINE -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/port -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/giflib/5.1.4/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/giflib/5.1.4/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libjpeg/9d/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libjpeg/9d/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libgeotiff/1.6.0/_/_/package/a9fbdb19bebdff8d60cc4f20198ff2e86ea26a06/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libtiff/4.1.0/_/_/package/4cfb872a7d959dfb53da0abead498a7ffe3cbe72/include -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libpng/1.6.37/_/_/package/a5db9977b995c3a52f6068c4befeb555e2aa78ee -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libpng/1.6.37/_/_/package/a5db9977b995c3a52f6068c4befeb555e2aa78ee/include  -DGDAL_COMPILATION -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/json-c/0.13.1/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/include/json-c  -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/ogr/ogrsf_frmts/geojson -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/ogr/ogrsf_frmts/generic -g -I/tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/gnm -c -o gdaladdo.lo gdaladdo.cpp

Link:

/bin/bash /tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/libtool --mode=link --silent clang++ -std=c++11 -m64 -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/json-c/0.13.1/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libgeotiff/1.6.0/_/_/package/a9fbdb19bebdff8d60cc4f20198ff2e86ea26a06/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/flatbuffers/1.12.0/_/_/package/ab1732eaa9b018f8ce55e42c1863eee4f20db10b/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libiconv/1.16/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libpng/1.6.37/_/_/package/a5db9977b995c3a52f6068c4befeb555e2aa78ee/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/giflib/5.1.4/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/geos/3.8.1/_/_/package/819c37cee2f8127f8ac8b5386c4ba4a3c58e0afb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/proj/7.0.0/_/_/package/9e8e2da8da6517b3d18441049c73f8deeec5224e/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libtiff/4.1.0/_/_/package/4cfb872a7d959dfb53da0abead498a7ffe3cbe72/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/sqlite3/3.31.1/_/_/package/8726bdb7fed1c9d10784d2490c79f6b14c4fe44d/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libcurl/7.69.1/_/_/package/32b2c6d4da512dd3d22600a1021c80fca6ac4095/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/zlib/1.2.11/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/xz_utils/5.2.4/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libjpeg/9d/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/jbig/20160605/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/zstd/1.4.3/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/libwebp/1.0.3/_/_/package/6a842bb5bec37e0c6199fd57aedd95fdcc7cbc98/lib -L/tmp/c3ipr/pr_1722_5_0_48/.conan/data/openssl/1.1.1g/_/_/package/689541ef75e69f6ec6dadbae4187260d6a3f4cfb/lib gdaladdo.lo  /tmp/c3ipr/pr_1722_5_0_48/.conan/data/gdal/3.1.0/_/_/build/24258629af78ec0a2e509c7d4fa7fdf23ae5f854/source_subfolder/libgdal.la -o gdaladdo

Error at link time:

/usr/bin/ld: .libs/gdaladdo.o: undefined reference to symbol '_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm'
//usr/lib/x86_64-linux-gnu/libc++.so.1: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Each command is a little bit long :p but you can see that -stdlib=libc++ is used for compilation but not for link. If -stdlib=libc++ is also added for link, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants