conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
967 stars 1.78k forks source link

[package] libpq/15.4: MinGW undefined references when using libpq #25282

Open scandyna opened 2 months ago

scandyna commented 2 months ago

Description

While building qt/6.7.1 on Windows with MinGW gcc 13, there are a lot of undefined references, like:

C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: qtbase/src/plugins/sqldrivers/psql/CMakeFiles/QPSQLDriverPlugin.dir/qsql_psql.cpp.obj: in function `QPSQLResult::isNull(int)':
C:/.conan/6faa1d/1/src/qtbase/src/plugins/sqldrivers/psql/qsql_psql.cpp:675: undefined reference to `PQgetisnull'

An example of a failing build of Qt6 is available here: https://gitlab.com/scandyna/conan-qt-builds/-/jobs/7827688162/viewer

The problem is also reproducible with the test_package provided in the libpq recipe. An example of a failing conan test is available here: https://gitlab.com/scandyna/conan-center-index-partialbasicci-sandbox/-/jobs/7833187239

Package and Environment Details

Conan profile

Configuration (profile_host): [settings] arch=x86_64 build_type=Debug compiler=gcc compiler.cppstd=17 compiler.crt=ucrt compiler.exception=seh compiler.libcxx=libstdc++11 compiler.threads=posix compiler.version=13 os=Windows [options] icu:shared=False libalsa:shared=True libpq:shared=False qt:gui=True qt:qtserialport=True qt:shared=True qt:widgets=True qt:with_glib=False qt:with_mysql=False qt:with_odbc=True qt:with_pq=True qt:with_sqlite3=True qt:with_vulkan=False zlib:shared=False [build_requires] [env] CC=gcc CXX=g++ [conf] tools.build:compiler_executables={'c': 'C:/MinGW/mingw64/bin/gcc.exe', 'cpp': 'C:/MinGW/mingw64/bin/g++.exe'} [buildenv] CC=gcc CXX=g++ PATH=+(path)/MinGW/mingw64/bin [runenv] PATH=+(path)/MinGW/mingw64/bin Configuration (profile_build): [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=17 compiler.crt=ucrt compiler.exception=seh compiler.libcxx=libstdc++11 compiler.threads=posix compiler.version=13 os=Windows [options] icu:shared=False libalsa:shared=True qt:gui=True qt:qtserialport=True qt:shared=True qt:widgets=True qt:with_glib=False qt:with_mysql=False qt:with_odbc=True qt:with_pq=True qt:with_sqlite3=True qt:with_vulkan=False zlib:shared=False [build_requires] [env] CC=gcc CXX=g++ [conf] tools.build:compiler_executables={'c': 'C:/MinGW/mingw64/bin/gcc.exe', 'cpp': 'C:/MinGW/mingw64/bin/g++.exe'} [buildenv] CC=gcc CXX=g++ PATH=+(path)/MinGW/mingw64/bin [runenv] PATH=+(path)/MinGW/mingw64/bin

Steps to reproduce

cd conan-center-index/recipes/libpq/all

conan create . libpq/15.4@ --profile:build windows_gcc13_x86_64_build_qt --profile:host windows_gcc13_x86_64_build_qt --settings:build build_type=Release --settings:host build_type=Debug --options:host libpq:shared=False --test-folder None --build missing --build libpq --update

conan test test_package libpq/15.4@ --profile:build windows_gcc13_x86_64_build_qt --profile:host windows_gcc13_x86_64_build_qt --settings:build build_type=Release --settings:host build_type=Debug --options:host libpq:shared=False

Logs

Click to expand log ``` $ conan test test_package libpq/$LIBPQ_VERSION@ --profile:build $CONAN_PROFILE_BUILD --profile:host $CONAN_PROFILE_HOST --settings:build build_type=Release --settings:host build_type=$BUILD_TYPE --options:host libpq:shared=$BUILD_SHARED_LIBS WARN: *** Conan 1 is legacy and on a deprecation path *** WARN: *** Please upgrade to Conan 2 *** Configuration (profile_host): [settings] arch=x86_64 build_type=Debug compiler=gcc compiler.cppstd=17 compiler.crt=ucrt compiler.exception=seh compiler.libcxx=libstdc++11 compiler.threads=posix compiler.version=13 os=Windows [options] icu:shared=False libalsa:shared=True libpq:shared=False qt:gui=True qt:qtserialport=True qt:shared=True qt:widgets=True qt:with_glib=False qt:with_mysql=False qt:with_odbc=True qt:with_pq=True qt:with_sqlite3=True qt:with_vulkan=False zlib:shared=False [build_requires] [env] CC=gcc CXX=g++ [conf] tools.build:compiler_executables={'c': 'C:/MinGW/mingw64/bin/gcc.exe', 'cpp': 'C:/MinGW/mingw64/bin/g++.exe'} [buildenv] CC=gcc CXX=g++ PATH=+(path)/MinGW/mingw64/bin [runenv] PATH=+(path)/MinGW/mingw64/bin Configuration (profile_build): [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=17 compiler.crt=ucrt compiler.exception=seh compiler.libcxx=libstdc++11 compiler.threads=posix compiler.version=13 os=Windows [options] icu:shared=False libalsa:shared=True qt:gui=True qt:qtserialport=True qt:shared=True qt:widgets=True qt:with_glib=False qt:with_mysql=False qt:with_odbc=True qt:with_pq=True qt:with_sqlite3=True qt:with_vulkan=False zlib:shared=False [build_requires] [env] CC=gcc CXX=g++ [conf] tools.build:compiler_executables={'c': 'C:/MinGW/mingw64/bin/gcc.exe', 'cpp': 'C:/MinGW/mingw64/bin/g++.exe'} [buildenv] CC=gcc CXX=g++ PATH=+(path)/MinGW/mingw64/bin [runenv] PATH=+(path)/MinGW/mingw64/bin libpq/15.4 (test package): Installing package Requirements libpq/15.4 from local cache - Cache Packages libpq/15.4:19b369753531268bb7660290d71f992b141d7b72 - Cache Installing (downloading, building) binaries... libpq/15.4: Already installed! libpq/15.4 (test package): Generator 'CMakeToolchain' calling 'generate()' libpq/15.4 (test package): Preset 'debug' added to CMakePresets.json. Invoke it manually using 'cmake --preset debug' libpq/15.4 (test package): If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE=C:\builds\scandyna\conan-center-index-partialbasicci-sandbox\conan-center-index\recipes\libpq\all\test_package\build\Debug\generators\conan_toolchain.cmake -DCMAKE_SH=CMAKE_SH-NOTFOUND -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Debug' libpq/15.4 (test package): Generator 'VirtualRunEnv' calling 'generate()' libpq/15.4 (test package): Generator 'CMakeDeps' calling 'generate()' libpq/15.4 (test package): Generator txt created conanbuildinfo.txt libpq/15.4 (test package): Aggregating env generators libpq/15.4 (test package): Generated conaninfo.txt libpq/15.4 (test package): Generated graphinfo Using lockfile: 'C:\builds\scandyna\conan-center-index-partialbasicci-sandbox\conan-center-index\recipes\libpq\all\test_package\build\Debug\generators/conan.lock' Using cached profile from lockfile [HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] 'fPIC' option not found [HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK libpq/15.4 (test package): Calling build() libpq/15.4 (test package): CMake command: cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="C:/builds/scandyna/conan-center-index-partialbasicci-sandbox/conan-center-index/recipes/libpq/all/test_package/build/Debug/generators/conan_toolchain.cmake" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Debug" "C:\builds\scandyna\conan-center-index-partialbasicci-sandbox\conan-center-index\recipes\libpq\all\test_package\." -- Using Conan toolchain: C:/builds/scandyna/conan-center-index-partialbasicci-sandbox/conan-center-index/recipes/libpq/all/test_package/build/Debug/generators/conan_toolchain.cmake -- Conan toolchain: C++ Standard 17 with extensions OFF -- The C compiler identification is GNU 13.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/MinGW/mingw64/bin/gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Conan: Component target declared 'libpq::pgport' -- Conan: Component target declared 'libpq::pgcommon' -- Conan: Component target declared 'libpq::pq' -- Conan: Target declared 'PostgreSQL::PostgreSQL' -- Configuring done (2.0s) -- Generating done (0.1s) CMake Warning: Manually-specified variables were not used by the project: CMAKE_POLICY_DEFAULT_CMP0091 CMAKE_SH -- Build files have been written to: C:/builds/scandyna/conan-center-index-partialbasicci-sandbox/conan-center-index/recipes/libpq/all/test_package/build/Debug libpq/15.4 (test package): CMake command: cmake --build "C:\builds\scandyna\conan-center-index-partialbasicci-sandbox\conan-center-index\recipes\libpq\all\test_package\build\Debug" -- -j2 [ 50%] Building C object CMakeFiles/test_package.dir/test_package.c.obj [100%] Linking C executable test_package.exe C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\test_package.dir/objects.a(test_package.c.obj): in function `main': C:/builds/scandyna/conan-center-index-partialbasicci-sandbox/conan-center-index/recipes/libpq/all/test_package/test_package.c:9: undefined reference to `PQlibVersion' C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/builds/scandyna/conan-center-index-partialbasicci-sandbox/conan-center-index/recipes/libpq/all/test_package/test_package.c:12: undefined reference to `PQconnectdb' C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/builds/scandyna/conan-center-index-partialbasicci-sandbox/conan-center-index/recipes/libpq/all/test_package/test_package.c:13: undefined reference to `PQstatus' C:/MinGW/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/builds/scandyna/conan-center-index-partialbasicci-sandbox/conan-center-index/recipes/libpq/all/test_package/test_package.c:15: undefined reference to `PQfinish' collect2.exe: error: ld returned 1 exit status mingw32-make[2]: *** [CMakeFiles\test_package.dir\build.make:104: test_package.exe] Error 1 mingw32-make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/test_package.dir/all] Error 2 mingw32-make: *** [Makefile:90: all] Error 2 ERROR: libpq/15.4 (test package): Error in build() method, line 21 cmake.build() ConanException: Error 2 while executing cmake --build "C:\builds\scandyna\conan-center-index-partialbasicci-sandbox\conan-center-index\recipes\libpq\all\test_package\build\Debug" -- -j2 ```
scandyna commented 2 months ago

I could not paste all the logs. Here is a file with all: build_test_libpq_mingw13_logs.txt

They come from this build job: https://gitlab.com/scandyna/conan-center-index-partialbasicci-sandbox/-/jobs/7833639498

scandyna commented 1 month ago

I looked in a created package, and seen that libpq.a is an empty file. Also looked what patches/15/001-mingw-build-static-libraries.patch does, and found something missing. I'm testing an update on my side, and will submit a PR if ok.