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

[apr-util] on windows : port installs incorrect apu.h header #27301

Closed
d6p opened this issue Oct 18, 2022 · 3 comments · Fixed by #27456
Closed

[apr-util] on windows : port installs incorrect apu.h header #27301

d6p opened this issue Oct 18, 2022 · 3 comments · Fixed by #27456
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@d6p
Copy link

d6p commented Oct 18, 2022

Describe the bug
on Windows Server 2022 & visual studio 2022, apache httpd build breaks when referencing vcpkg installed apr-util.

Environment

  • OS: Windows Server 2022
  • Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.15.26732.1

To Reproduce
Steps to reproduce the behavior:

  1. ./vcpkg install apr-util:x64-windows
    apr-util builds successfully as a dynamic library.

  2. build apache httpd, referencing vcpkg installed lib.
    link fails due to apr-util related unresolved external symbols.

Expected behavior
link succeeds.

Failure logs
LINK: command "C:\PROGRA2\MICROS2\2022\BUILDT1\VC\Tools\MSVC\14321.313\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\libhttpd.dir\objects1.rsp /out:libhttpd.dll /implib:libhttpd.lib /pdb:C:\Users\integration\Sandbox\apache-httpd\build\httpd\libhttpd.pdb /dll /version:0.0 /base:@C:/Users/integration/Sandbox/apache-httpd/build/httpd/BaseAddr.ref,libhttpd.dll /machine:x64 /INCREMENTAL:NO C:\Users\integration\Sandbox\vcpkg\installed\x64-windows\lib\libapr-1.lib C:\Users\integration\Sandbox\vcpkg\installed\x64-windows\lib\libaprutil-1.lib C:\Users\integration\Sandbox\vcpkg\installed\x64-windows\lib\apr_ldap-1.lib C:\Users\integration\Sandbox\vcpkg\installed\x64-windows\lib\pcre2-8.lib ws2_32.lib mswsock.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:libhttpd.dll.manifest" failed (exit code 1120) with the following output:
Creating library libhttpd.lib and object libhttpd.exp
util_xml.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
request.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
util.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
util_filter.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
util_script.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
byterange_filter.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
chunk_filter.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
http_filters.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
protocol.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_eos
chunk_filter.c.obj : error LNK2019: unresolved external symbol apr_bucket_type_flush referenced in function ap_http_chunk_filter
core_filters.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_flush
protocol.c.obj : error LNK2001: unresolved external symbol apr_bucket_type_flush
ssl.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
scoreboard.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
util_expr_eval.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
util_filter.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
log.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
mpm_common.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
protocol.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
request.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
http_protocol.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
config.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
connection.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
core.c.obj : error LNK2001: unresolved external symbol apr_hook_global_pool
ssl.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
scoreboard.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
util_expr_eval.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
log.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
mpm_common.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
protocol.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
request.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
http_protocol.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
config.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
connection.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
core.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_enabled
ssl.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
scoreboard.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
util_expr_eval.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
log.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
mpm_common.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
protocol.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
request.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
http_protocol.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
config.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
connection.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
core.c.obj : error LNK2001: unresolved external symbol apr_hook_debug_current
core_filters.c.obj : error LNK2019: unresolved external symbol apr_bucket_type_file referenced in function ap_core_output_filter
core_filters.c.obj : error LNK2019: unresolved external symbol apr_bucket_type_heap referenced in function is_in_memory_bucket
core_filters.c.obj : error LNK2019: unresolved external symbol apr_bucket_type_pool referenced in function is_in_memory_bucket
core_filters.c.obj : error LNK2019: unresolved external symbol apr_bucket_type_immortal referenced in function is_in_memory_bucket
core_filters.c.obj : error LNK2019: unresolved external symbol apr_bucket_type_transient referenced in function is_in_memory_bucket
libhttpd.dll : fatal error LNK1120: 10 unresolved externals

Additional context
The root cause is that the portfile.cmake file contains the following lines:

    file(READ ${CURRENT_PACKAGES_DIR}/include/apu.h  APU_H)
    if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
      string(REPLACE "defined(APU_DECLARE_EXPORT)" "1" APU_H "${APU_H}")
    else()
      string(REPLACE "defined(APU_DECLARE_STATIC)" "1" APU_H "${APU_H}")
    endif()
    file(WRITE ${CURRENT_PACKAGES_DIR}/include/apu.h "${APU_H}")

The above code results in the installed apu.h header containing the following logic :

#define APU_DECLARE_DATA
#elif defined(APU_DECLARE_STATIC)
#define APU_DECLARE(type)            type __stdcall
#define APU_DECLARE_NONSTD(type)     type __cdecl
#define APU_DECLARE_DATA
#elif 1
#define APU_DECLARE(type)            __declspec(dllexport) type __stdcall
#define APU_DECLARE_NONSTD(type)     __declspec(dllexport) type __cdecl
#define APU_DECLARE_DATA             __declspec(dllexport)
#else
#define APU_DECLARE(type)            __declspec(dllimport) type __stdcall
#define APU_DECLARE_NONSTD(type)     __declspec(dllimport) type __cdecl
#define APU_DECLARE_DATA             __declspec(dllimport)
#endif

which prevents the dllimport section (which is needed when referencing the dynamic library symbol from another build) from being reachable.

Removing the portfile.cmake questionable lines fixes the problem.

@LilyWangLL LilyWangLL self-assigned this Oct 18, 2022
@LilyWangLL LilyWangLL added the category:port-bug The issue is with a library, which is something the port should already support label Oct 18, 2022
@Neumann-A
Copy link
Contributor

Neumann-A commented Oct 19, 2022

    if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
      string(REPLACE "defined(APU_DECLARE_EXPORT)" "1" APU_H "${APU_H}")
    else()
      string(REPLACE "defined(APU_DECLARE_STATIC)" "1" APU_H "${APU_H}")
    endif()

should be

    if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
      string(REPLACE "defined(APU_DECLARE_STATIC)" "0" APU_H "${APU_H}")
    else()
      string(REPLACE "defined(APU_DECLARE_STATIC)" "1" APU_H "${APU_H}")
    endif()

@LilyWangLL
Copy link
Contributor

@d6p Could you test the PR #27456 fix your issue? Thanks Neumann's help.

@d6p
Copy link
Author

d6p commented Oct 26, 2022

Just did that, httpd builds OK with it. Looks good to me, thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants