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

Linking to prebuilt binaries raises StdFill not defined on MacOS #174

Open
afossa opened this issue Sep 27, 2024 · 1 comment
Open

Linking to prebuilt binaries raises StdFill not defined on MacOS #174

afossa opened this issue Sep 27, 2024 · 1 comment

Comments

@afossa
Copy link

afossa commented Sep 27, 2024

I am building a Julia wrapper to the dace C++ library using CxxWrap. When building on MacOS and linking against the precompiled binaries for libcxxwrap pulled from GitHub, the wrapper is installed correctly. However, upon trying

julia> using DACE

in Julia, an error is thrown:

ERROR: LoadError: UndefVarError: `StdFill` not defined

this error does not appear if I also build libcxxwrap locally, and then link my library to the latter. Moreover, it seems to affect only MacOS (both Intel and Apple Silicon). On Linux, I can use my library with the precompiled libcxxwrap without issues.

This is the wrapper I am building against libcxxwrap: https://github.com/afossa/dace/tree/eigen_interface
After compilation, it is installed in an override directory for https://github.com/JuliaBinaryWrappers/DACE_jll.jl which is a dependency of https://github.com/afossa/DACE.jl/tree/eigen_interface

When I build against the precompiled libcxxwrap, the CMake configuration looks like this:

-- The C compiler identification is AppleClang 16.0.0.16000026
-- The CXX compiler identification is AppleClang 16.0.0.16000026
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Eigen3 v3.4.0: /usr/local/share/eigen3/cmake
-- Found Julia executable: /Users/afossa/.juliaup/bin/julia
-- Julia_VERSION_STRING: 1.10.5
-- Julia_INCLUDE_DIRS:   /Users/afossa/.julia/juliaup/julia-1.10.5+0.x64.apple.darwin14/include/julia
-- Julia_LIBRARY_DIR:    /Users/afossa/.julia/juliaup/julia-1.10.5+0.x64.apple.darwin14/lib
-- Julia_LIBRARY:        /Users/afossa/.julia/juliaup/julia-1.10.5+0.x64.apple.darwin14/lib/libjulia.1.10.5.dylib
-- JULIA_HOME:           /Users/afossa/.julia/juliaup/julia-1.10.5+0.x64.apple.darwin14/bin
-- Julia_LLVM_VERSION:   v15.0.7
-- Julia_WORD_SIZE:      64
-- Found Julia: /Users/afossa/.julia/juliaup/julia-1.10.5+0.x64.apple.darwin14/lib/libjulia.1.10.5.dylib (found version "1.10.5")
-- Found JlCxx v0.13.2: /Users/afossa/.julia/artifacts/1f69a3fdca4f1d2810e02a7e336190c3981570bd/lib/cmake/JlCxx
-- Looking for strncpy_s
-- Looking for strncpy_s - not found
-- Enabling custom exit function
-- Configuring done (3.7s)
-- Generating done (0.0s)

with this configuration, libdace is built correctly, but after trying to load it in Julia, I obtain the following:

ERROR: LoadError: UndefVarError: `StdFill` not defined
Stacktrace:
  [1] getproperty(x::Module, f::Symbol)
    @ Base ./Base.jl:31
  [2] top-level scope
    @ none:1
  [3] eval
    @ ./boot.jl:385 [inlined]
  [4] wrap_functions(functions::Vector{CxxWrap.CxxWrapCore.CppFunctionInfo}, julia_mod::Module)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:773
  [5] wrapfunctions(jlmod::Module)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:790
  [6] wrapmodule(so_path_cb::Function, funcname::Symbol, m::Module, flags::Nothing)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:827
  [7] top-level scope
    @ ~/.julia/dev/DACE/src/DACE.jl:20
  [8] include
    @ ./Base.jl:495 [inlined]
  [9] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [10] top-level scope
    @ stdin:3
in expression starting at /Users/afossa/.julia/dev/DACE/src/DACE.jl:1
in expression starting at stdin:3
  ✗ DACE
  0 dependencies successfully precompiled in 4 seconds. 101 already precompiled.

ERROR: The following 1 direct dependency failed to precompile:

DACE [f4439622-e757-4457-9ca0-f65a61d23f40]

Failed to precompile DACE [f4439622-e757-4457-9ca0-f65a61d23f40] to "/Users/afossa/.julia/compiled/v1.10/DACE/jl_fRdVek".
ERROR: LoadError: UndefVarError: `StdFill` not defined
Stacktrace:
  [1] getproperty(x::Module, f::Symbol)
    @ Base ./Base.jl:31
  [2] top-level scope
    @ none:1
  [3] eval
    @ ./boot.jl:385 [inlined]
  [4] wrap_functions(functions::Vector{CxxWrap.CxxWrapCore.CppFunctionInfo}, julia_mod::Module)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:773
  [5] wrapfunctions(jlmod::Module)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:790
  [6] wrapmodule(so_path_cb::Function, funcname::Symbol, m::Module, flags::Nothing)
    @ CxxWrap.CxxWrapCore ~/.julia/packages/CxxWrap/eWADG/src/CxxWrap.jl:827
  [7] top-level scope
    @ ~/.julia/dev/DACE/src/DACE.jl:20
  [8] include
    @ ./Base.jl:495 [inlined]
  [9] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
    @ Base ./loading.jl:2222
 [10] top-level scope
    @ stdin:3
in expression starting at /Users/afossa/.julia/dev/DACE/src/DACE.jl:1
in expression starting at stdin:

However, if I clone the source code of libcxxwrap (main branch), I build it locally as described in your README, and then I rebuild my library against it, I have no issues in using DACE. In this case, the only change in the CMake configuration is:

-- Found JlCxx v0.13.2: /Users/afossa/.julia/dev/libcxxwrap_julia_jll/override/lib/cmake/JlCxx

which now points to the libcxxwrap libraries that I compiled myself.

Last point to mention: pulling DACE and all its dependencies (including DACE_jll and libcxxwrap) from the julia package registry (i.e. using the binaries for libcxxwrap and libdace built on GitHub) and just use the library as it is does not result in any error being thrown.

@barche
Copy link
Contributor

barche commented Sep 28, 2024

Yes, unfortunately this happens because of differences in C++ compiler version between the binaries from Github (cross-compiled using BinaryBuilder) and the native AppleClang compiler. The safest way to develop locally is to build julia, libcxxwrap-julia and your library all with the same compiler. Once you are happy with how it works locally, you can then distribute the result via Yggdrasil.

It may also be possible to develop in a docker container, though I haven't tried this in a long time.

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

2 participants