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

link failure with mingw #283

Open
star-hengxing opened this issue Nov 20, 2024 · 0 comments
Open

link failure with mingw #283

star-hengxing opened this issue Nov 20, 2024 · 0 comments

Comments

@star-hengxing
Copy link

star-hengxing commented Nov 20, 2024

version: v0.12.1
full log: https://github.com/xmake-io/xmake-repo/actions/runs/11916365319/job/33208859126?pr=5783

{
  license = "Apache-2.0",
  libfiles = {
    "C:\Users\star\AppData\Local\.xmake\packages\l\libcoro\v0.12.1\0e3833677e234bbcb1d989de31a06b49\lib\liblibcoro.dll.a",
    "C:\Users\star\AppData\Local\.xmake\packages\l\libcoro\v0.12.1\0e3833677e234bbcb1d989de31a06b49\bin\libcoro.dll"
  },
  version = "v0.12.1",
  linkdirs = {
    "C:\Users\star\AppData\Local\.xmake\packages\l\libcoro\v0.12.1\0e3833677e234bbcb1d989de31a06b49\lib"
  },
  static = true,
  links = {
    "libcoro"
  },
  shared = true,
  includedirs = {
    "C:\Users\star\AppData\Local\.xmake\packages\l\libcoro\v0.12.1\0e3833677e234bbcb1d989de31a06b49\include"
  }
}

checking for C:\msys64\mingw64\bin\x86_64-w64-mingw32-g++ ... ok
checking for flags (-std=c++20) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\.xmake\241120\_94B2CCDD690146708353F92630D437D0.o:_F157041C661645FDB44707D8887E67B9.cpp:(.text$_ZN4coro9sync_waitINS_4taskIyEEOyEEDcOT_[_ZN4coro9sync_waitINS_4taskIyEEOyEEDcOT_]+0x1c): undefined reference to `coro::detail::sync_wait_event::sync_wait_event(bool)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\.xmake\241120\_94B2CCDD690146708353F92630D437D0.o:_F157041C661645FDB44707D8887E67B9.cpp:(.text$_ZN4coro9sync_waitINS_4taskIyEEOyEEDcOT_[_ZN4coro9sync_waitINS_4taskIyEEOyEEDcOT_]+0x5e): undefined reference to `coro::detail::sync_wait_event::wait()'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\tmp\.xmake\241120\_94B2CCDD690146708353F92630D437D0.o:_F157041C661645FDB44707D8887E67B9.cpp:(.text$_ZZN4coro6detail22sync_wait_task_promiseIOyE13final_suspendEvENK19completion_notifier13await_suspendENSt7__n486116coroutine_handleIS3_EE[_ZZN4coro6detail22sync_wait_task_promiseIOyE13final_suspendEvENK19completion_notifier13await_suspendENSt7__n486116coroutine_handleIS3_EE]+0x23): undefined reference to `coro::detail::sync_wait_event::set()'
collect2.exe: error: ld returned 1 exit status

test code:

auto make_task_inline = [](uint64_t x) -> coro::task<uint64_t> { co_return x + x; };
auto result = coro::sync_wait(make_task_inline(5));

I check the dll export table, only this symbols (global variable) are exported.

_ZN4coro9semaphore22acquire_result_unknownB5cxx11E
_ZN4coro9semaphore23acquire_result_acquiredB5cxx11E
_ZN4coro9semaphore32acquire_result_semaphore_stoppedB5cxx11E

Thanks to the work of #236, I check the code in the generated file export.hpp

#ifdef CORO_STATIC_DEFINE
#  define CORO_EXPORT
#  define CORO_NO_EXPORT
#else
#  ifndef CORO_EXPORT
#    ifdef libcoro_EXPORTS
        /* We are building this library */
#      define CORO_EXPORT __declspec(dllexport)
#    else
        /* We are using this library */
#      define CORO_EXPORT __declspec(dllimport)
#    endif
#  endif

Then I try to add cxflags -DCORO_EXPORT= override the __declspec(dllexport), it work.

https://sourceware.org/binutils/docs/ld.html#Options-Specific-to-i386-PE-Targets

--export-all-symbols
If given, all global symbols in the objects used to build a DLL will be exported by the DLL. Note that this is the default if there otherwise wouldn’t be any exported symbols.

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

No branches or pull requests

1 participant