conda-forge / flang-activation-feedstock

A conda-smithy repository for flang-activation.
BSD 3-Clause "New" or "Revised" License
1 stars 4 forks source link

Flang 19 build does not export symbols #13

Open awvwgk opened 1 week ago

awvwgk commented 1 week ago

When building DLLs with flang 19 via meson, linking of executables against the DLL fails due to not visible symbols.

Example: pipeline (https://github.com/conda-forge/mctc-lib-feedstock/pull/17)

[75/77] Linking target app/mctc-convert.exe
FAILED: app/mctc-convert.exe app/mctc-convert.pdb 
"flang-new"  -Wl,/OUT:app/mctc-convert.exe app/mctc-convert.exe.p/main.f90.obj "-I%PREFIX%\Library\include" "-Wl,/nologo" "-Wl,/DEBUG" "-Wl,/PDB:app\mctc-convert.pdb" "-Wl,-defaultlib:D:/bld/mctc-lib_1730787576340/_build_env/lib/clang/19/lib/windows/clang_rt.builtins-x86_64.lib" "-D_CRT_SECURE_NO_WARNINGS" "-fms-runtime-lib=dll" "-fuse-ld=lld" "mctc-lib.lib" "-Wl,/SUBSYSTEM:CONSOLE"
lld-link: error: undefined symbol: _QMmctc_io_readPread_structure_from_file
>>> referenced by %SRC_DIR%\app\main.f90:63
>>>               app/mctc-convert.exe.p/main.f90.obj:(_QQmain)
>>> referenced by %SRC_DIR%\app\main.f90:75
>>>               app/mctc-convert.exe.p/main.f90.obj:(_QQmain)

lld-link: error: undefined symbol: _QMmctc_io_readPread_structure_from_unit
>>> referenced by %SRC_DIR%\app\main.f90:73
>>>               app/mctc-convert.exe.p/main.f90.obj:(_QQmain)
>>> referenced by %SRC_DIR%\app\main.f90:61
>>>               app/mctc-convert.exe.p/main.f90.obj:(_QQmain)

...

flang-new: error: linker command failed with exit code 1 (use -v to see invocation)

Example: pipeline (https://github.com/conda-forge/toml-f-feedstock/pull/13)

[56/64] Linking target test/version/tftest-version.exe
FAILED: test/version/tftest-version.exe test/version/tftest-version.pdb 
"flang-new"  -Wl,/OUT:test/version/tftest-version.exe test/version/tftest-version.exe.p/version.f90.obj "-I%PREFIX%\Library\include" "-Wl,/nologo" "-Wl,/DEBUG" "-Wl,/PDB:test\version\tftest-version.pdb" "-Wl,--allow-multiple-definition" "-Wl,-defaultlib:D:/bld/toml-f_1730763821033/_build_env/lib/clang/19/lib/windows/clang_rt.builtins-x86_64.lib" "-D_CRT_SECURE_NO_WARNINGS" "-fms-runtime-lib=dll" "-fuse-ld=lld" "toml-f.lib" "-Wl,/SUBSYSTEM:CONSOLE"
lld-link: warning: ignoring unknown argument '--allow-multiple-definition'

lld-link: error: undefined symbol: _QMtomlf_versionPget_tomlf_version

>>> referenced by %SRC_DIR%\test\version\version.f90:23

>>>               test/version/tftest-version.exe.p/version.f90.obj:(_QQmain)

flang-new: error: linker command failed with exit code 1 (use -v to see invocation)

Environment: conda info

     active environment : base
    active env location : D:\Miniforge
            shell level : 1
       user config file : C:\Users\VssAdministrator\.condarc
 populated config files : D:\Miniforge\.condarc
                          C:\Users\VssAdministrator\.condarc
          conda version : 24.9.2
    conda-build version : 24.9.0
         python version : 3.12.7.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=x86_64_v4
                          __conda=24.9.2=0
                          __win=0=0
       base environment : D:\Miniforge  (writable)
      conda av data dir : D:\Miniforge\etc\conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : D:\Miniforge\pkgs
                          C:\Users\VssAdministrator\.conda\pkgs
                          C:\Users\VssAdministrator\AppData\Local\conda\conda\pkgs
       envs directories : D:\Miniforge\envs
                          C:\Users\VssAdministrator\.conda\envs
                          C:\Users\VssAdministrator\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/24.9.2 requests/2.32.3 CPython/3.12.7 Windows/2022Server Windows/10.0.20348 solver/libmamba conda-libmamba-solver/24.9.0 libmambapy/1.5.10
          administrator : True
             netrc file : None
           offline mode : False

Environment: conda list

    flang:              19.1.3-hbeecb71_0         conda-forge
    flang_impl_win-64:  19.1.3-h719f0c7_2         conda-forge
    flang_win-64:       19.1.3-h719f0c7_2         conda-forge
h-vetinari commented 1 week ago

If those symbols are coming from the C/C++ side, they probably need to be annotated by __declspec(dllimport), because now that part is handled by MSVC, which doesn't export images by default (in contrast to gcc through m2w64_*)