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

The Build Failure in Msys #4598

Open
TabNahida opened this issue Jul 2, 2024 · 2 comments
Open

The Build Failure in Msys #4598

TabNahida opened this issue Jul 2, 2024 · 2 comments

Comments

@TabNahida
Copy link

TabNahida commented Jul 2, 2024

Describe the bug
I want to repack Poco for xrepo in msys platform. When I build poco for test, I receive build failure.

To Reproduce

xmake.lua

package("poco")
    set_homepage("https://pocoproject.org/")
    set_description("The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.")
    set_license("BSL-1.0")

    add_urls("https://github.com/pocoproject/poco/archive/refs/tags/poco-$(version)-release.tar.gz",
             "https://github.com/pocoproject/poco.git")

    add_versions("1.11.0", "8a7bfd0883ee95e223058edce8364c7d61026ac1882e29643822ce9b753f3602")
    add_versions("1.11.1", "2412a5819a239ff2ee58f81033bcc39c40460d7a8b330013a687c8c0bd2b4ac0")
    add_versions("1.11.6", "ef0ac1bd1fe4d84b38cde12fbaa7a441d41bfbd567434b9a57ef8b79a8367e74")
    add_versions("1.11.8", "a59727335a9bf428dc1289cd8ce84f9c1749c1472a0cd3ae86bec85be23d7cbe")
    add_versions("1.12.1", "debc6d5d5eb946bb14e47cffc33db4fffb4f11765f34f8db04e71e866d1af8f9")
    add_versions("1.12.2", "30442ccb097a0074133f699213a59d6f8c77db5b2c98a7c1ad9c5eeb3a2b06f3")
    add_versions("1.12.4", "71ef96c35fced367d6da74da294510ad2c912563f12cd716ab02b6ed10a733ef")
    add_versions("1.12.5", "92b18eb0fcd2263069f03e7cc80f9feb43fb7ca23b8c822a48e42066b2cd17a6")
    add_versions("1.13.3", "9f074d230daf30f550c5bde5528037bdab6aa83b2a06c81a25e89dd3bcb7e419")

    if is_plat("windows") then
        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
    end
    add_configs("mysql", {description = "Enable mysql support.", default = false, type = "boolean"})
    add_configs("postgresql", {description = "Enable postgresql support.", default = false, type = "boolean"})
    add_configs("mongodb", {description = "Enable mongodb support.", default = false, type = "boolean"})
    add_configs("odbc", {description = "Enable odbc support.", default = is_plat("windows"), type = "boolean"})

    add_deps("cmake")
    add_deps("openssl", "sqlite3", "expat", "zlib")
    add_defines("POCO_NO_AUTOMATIC_LIBS")
    if is_plat("windows") then
        add_syslinks("iphlpapi")
    end

    on_load("windows", "linux", "macosx", "mingw", "msys", function (package)

        if package:config("postgresql") then
            package:add("deps", "postgresql")
        end

        if package:config("mysql") then
            package:add("deps", "mysql")
        end

        if package:version():ge("1.12.0") then
            package:add("deps", "pcre2")
        else
            package:add("deps", "pcre")
        end

    end)

    on_install("windows", "linux", "macosx", "mingw", "msys", function (package)
        io.replace("XML/CMakeLists.txt", "EXPAT REQUIRED", "EXPAT CONFIG REQUIRED")
        io.replace("XML/CMakeLists.txt", "EXPAT::EXPAT", "expat::expat")
        io.replace("XML/CMakeLists.txt", "PUBLIC POCO_UNBUNDLED", "PUBLIC POCO_UNBUNDLED XML_DTD XML_NS")
        io.replace("Foundation/CMakeLists.txt", "PUBLIC POCO_UNBUNDLED", "PUBLIC POCO_UNBUNDLED PCRE_STATIC")
        io.replace("Foundation/CMakeLists.txt", "POCO_SOURCES%(SRCS RegExp.-%)", "")
        if package:version():ge("1.12.0") and package:dep("pcre2"):exists() and not package:dep("pcre2"):config("shared") then
            io.replace("cmake/FindPCRE2.cmake", "NAMES pcre2-8", "NAMES pcre2-8-static pcre2-8", {plain = true})
            io.replace("cmake/FindPCRE2.cmake", "IMPORTED_LOCATION \"${PCRE2_LIBRARY}\"", "IMPORTED_LOCATION \"${PCRE2_LIBRARY}\"\nINTERFACE_COMPILE_DEFINITIONS PCRE2_STATIC", {plain = true})
        end

        local configs = {"-DPOCO_UNBUNDLED=ON", "-DENABLE_TESTS=OFF", "-DENABLE_PDF=ON"}
        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
        if package:is_plat("windows") and not package:config("shared") then
            table.insert(configs, "-DPOCO_MT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
        end

        if package:is_plat("windows") then
            local vs_sdkver = import("core.tool.toolchain").load("msvc"):config("vs_sdkver")
            if vs_sdkver then
                local build_ver = string.match(vs_sdkver, "%d+%.%d+%.(%d+)%.?%d*")
                assert(tonumber(build_ver) >= 18362, "poco requires Windows SDK to be at least 10.0.18362.0")
                table.insert(configs, "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" .. vs_sdkver)
                table.insert(configs, "-DCMAKE_SYSTEM_VERSION=" .. vs_sdkver)
            end
        end

        for _, lib in ipairs({"mysql", "postgresql", "odbc", "mongodb"}) do
            table.insert(configs, "-DENABLE_DATA_" .. lib:upper() .. "=" .. (package:config(lib) and "ON" or "OFF"))
        end

        if package:is_plat("mingw", "msys") then 
            -- table.insert(configs, "-DENABLE_MONGODB=OFF")
            table.insert(configs, "-DPOCO_DATA_NO_SQL_PARSER=ON")
        end

        if package:config("mysql") then
            io.replace("Data/MySQL/include/Poco/Data/MySQL/MySQL.h", '#pragma comment(lib, "libmysql")', '', {plain = true})
            local libmysql = package:dep("mysql"):fetch()
            if libmysql then
                table.insert(configs, "-DMYSQL_INCLUDE_DIR=" .. table.concat(libmysql.includedirs or libmysql.sysincludedirs, ";"))
                table.insert(configs, "-DMYSQL_LIBRARY=" .. table.concat(libmysql.libfiles or {}, ";"))
            end
        end

        -- warning: only works on windows sdk 10.0.18362.0 and later
        import("package.tools.cmake").install(package, configs)
    end)

    on_test(function (package)
        assert(package:has_cxxtypes("Poco::BasicEvent<int>", {configs = {languages = "c++14"}, includes = "Poco/BasicEvent.h"}))
    end)

Then clone xrepo and run xmake l scripts/test.lua -v -D poco in xrepo directory

Expected behavior
Build fail

Logs

[695/713] C:\msys64\mingw64\bin\x86_64-w64-mingw32-g++.exe -DMINGW32 -DODBCVER=0x0300 -DPCRE2_STATIC -DPCRE_STATIC -DPOCO_DATA_NO_SQL_PARSER=1 -DPOCO_ENABLE_CPP11 -DPOCO_ENABLE_CPP14 -DPOCO_OS_FAMILY_WINDOWS -DPOCO_STATIC -DPOCO_THREAD_STACK_SIZE -DPOCO_UNBUNDLED -DPOCO_WIN32_UTF8 -DUNICODE -DWC_NO_BEST_FIT_CHARS=0x400 -DWINVER=0x500 -D_UNICODE -D_WIN32 -IC:/Users/TabYe/AppData/Local/.xmake/cache/packages/2407/p/poco/1.13.3/source/Zip/include -IC:/Users/TabYe/AppData/Local/.xmake/cache/packages/2407/p/poco/1.13.3/source/Zip/src -IC:/Users/TabYe/AppData/Local/.xmake/cache/packages/2407/p/poco/1.13.3/source/Foundation/include -m64 -m64 -O3 -DNDEBUG -std=gnu++17 -MD -MT Zip/CMakeFiles/Zip.dir/src/ZipUtil.cpp.obj -MF Zip\CMakeFiles\Zip.dir\src\ZipUtil.cpp.obj.d -o Zip/CMakeFiles/Zip.dir/src/ZipUtil.cpp.obj -c C:/Users/TabYe/AppData/Local/.xmake/cache/packages/2407/p/poco/1.13.3/source/Zip/src/ZipUtil.cpp
[696/713] C:\Windows\system32\cmd.exe /C "cd . && C:\msys64\mingw64\bin\x86_64-w64-mingw32-g++.exe -m64 -m64 -O3 -DNDEBUG -m64 -m64 ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/CodeGenerator.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/Compiler.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/HeaderGenerator.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/ImplGenerator.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/Parser.cpp.obj -o bin\poco-arc.exe -Wl,--out-implib,lib\libpoco-arc.dll.a -Wl,--major-image-version,0,--minor-image-version,0  lib/libPocoFoundation.a  lib/libPocoUtil.a  lib/libPocoXML.a  C:/msys64/mingw64/lib/libexpat.dll.a  -lm  lib/libPocoJSON.a  lib/libPocoFoundation.a  C:/msys64/mingw64/lib/libpcre2-8.dll.a  C:/msys64/mingw64/lib/libz.dll.a  -liphlpapi  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
FAILED: bin/poco-arc.exe
C:\Windows\system32\cmd.exe /C "cd . && C:\msys64\mingw64\bin\x86_64-w64-mingw32-g++.exe -m64 -m64 -O3 -DNDEBUG -m64 -m64 ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/CodeGenerator.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/Compiler.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/HeaderGenerator.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/ImplGenerator.cpp.obj ActiveRecord/Compiler/CMakeFiles/ActiveRecordCompiler.dir/src/Parser.cpp.obj -o bin\poco-arc.exe -Wl,--out-implib,lib\libpoco-arc.dll.a -Wl,--major-image-version,0,--minor-image-version,0  lib/libPocoFoundation.a  lib/libPocoUtil.a  lib/libPocoXML.a  C:/msys64/mingw64/lib/libexpat.dll.a  -lm  lib/libPocoJSON.a  lib/libPocoFoundation.a  C:/msys64/mingw64/lib/libpcre2-8.dll.a  C:/msys64/mingw64/lib/libz.dll.a  -liphlpapi  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libPocoFoundation.a(Unicode.cpp.obj):Unicode.cpp:(.rdata$.refptr._pcre2_ucp_gentype_8[.refptr._pcre2_ucp_gentype_8]+0x0): undefined reference to `_pcre2_ucp_gentype_8'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libPocoFoundation.a(Unicode.cpp.obj):Unicode.cpp:(.rdata$.refptr._pcre2_ucd_records_8[.refptr._pcre2_ucd_records_8]+0x0): undefined reference to `_pcre2_ucd_records_8'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libPocoFoundation.a(Unicode.cpp.obj):Unicode.cpp:(.rdata$.refptr._pcre2_ucd_stage1_8[.refptr._pcre2_ucd_stage1_8]+0x0): undefined reference to `_pcre2_ucd_stage1_8'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: lib/libPocoFoundation.a(Unicode.cpp.obj):Unicode.cpp:(.rdata$.refptr._pcre2_ucd_stage2_8[.refptr._pcre2_ucd_stage2_8]+0x0): undefined reference to `_pcre2_ucd_stage2_8'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

Please add relevant environment information:

  • Windows 11 23H2 and Msys2 lastest
  • Poco 1.13.3
  • mysql, postgresql, monogodb and odbc are set to false. openssl-1.1.1-w, sqlite3-3.46.0+0, expat-2.6.2, pcre2-10.42 and zlib-v1.3.1
@TabNahida TabNahida added the bug label Jul 2, 2024
@matejk
Copy link
Contributor

matejk commented Jul 5, 2024

@TabNahida , you are very welcome to further investigate the problem and provide solution in the form of a pull request.

@TabNahida
Copy link
Author

For this problem, in https://github.com/xmake-io/xmake-repo/blob/dev/packages/p/poco/xmake.lua, we just enable one platform which could pass the check on github action. In xmake-io/xmake-repo#4390, others report the similar build failure on msys2. I think is there some dependence are not listed in the package description?

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

3 participants