Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Changing compiler ABI #138

Open
TransGirlCodes opened this issue Nov 10, 2018 · 3 comments
Open

Changing compiler ABI #138

TransGirlCodes opened this issue Nov 10, 2018 · 3 comments

Comments

@TransGirlCodes
Copy link

I've got a working BinaryBuilder release for my package here: https://github.com/BenJWard/BSGBuilder/releases/tag/v0.6.0

When I use the build.jl file in a package on my local Mojave macbook pro, the following happens:

(v1.0) pkg> activate .
(BSG) pkg> add BinaryProvider
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
 Resolving package versions...
  Updating `~/Desktop/BSG/Project.toml`
  [b99e7846] + BinaryProvider v0.5.2
  Updating `~/Desktop/BSG/Manifest.toml`
 [no changes]

(BSG) pkg> build
  Building CxxWrap  `~/.julia/packages/CxxWrap/KcmSi/deps/build.log`
  Building BSG ──── `~/Desktop/BSG/deps/build.log`
 Resolving package versions...
┌ Error: Error building `BSG`: 
│ ERROR: LoadError: ArgumentError: Unable to find matching download for MacOS(:x86_64, compiler_abi=CompilerABI(:gcc8, :cxx03))
│ Stacktrace:
│  [1] choose_download(::Dict{Platform,Tuple{String,String}}, ::MacOS) at /Users/bward/.julia/packages/BinaryProvider/1nGWd/src/PlatformNames.jl:733
│  [2] top-level scope at none:0
│  [3] include at ./boot.jl:317 [inlined]
│  [4] include_relative(::Module, ::String) at ./loading.jl:1041
│  [5] include(::Module, ::String) at ./sysimg.jl:29
│  [6] include(::String) at ./client.jl:388
│  [7] top-level scope at none:0in expression starting at /Users/bward/Desktop/BSG/deps/build.jl:24
└ @ Pkg.Operations ~/github/julia/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1069

My binary releases only use cxx11 and either gcc8 or gcc7 as their compiler_abi options, because bsg really needs cxx11 as a minimum. Is there a way to change the cxx standard options when downloading a build?

@staticfloat
Copy link
Member

So the cxx11 and cxx03 tags are for the std::string and std::list ABI change that GCC underwent a few years ago. Essentially, you cannot pass an std::string from one ABI to another without terrible things happening. And so we auto-detect whether or not your Julia was built via a compiler using cxx03-style strings or not, and we refuse to link against binaries that were built with a different style of strings.

I see you have explicitly set your cxxabi tag to cxx11. I did intend to eventually create an audit pass in the same spirit as our gfortran linkage detection pass that would figure out which (if any) C++ ABI constraints were being imposed by this dependency, but that doesn't exist yet. I'm going to step out on a limb and guess that you set the :cxx11 ABI constraint thinking that it would do something like set -std=cxx11 on your compiler invocations, not realizing that it was talking about something related but distinct, the internal layout of std::string and std::list.

Have you tried just not setting the :cxx11 tag? I reiterate that this may be dangerous (if you ever pass std::string or std::list objects into/out of your library, this can crash Julia) but it may "just work".

The full solution (if needed) is to have a build script that sets CPPFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" for :cxx03 builds and =1 for :cxx11 builds, generating two tarballs per platform, just like we do for libgfortran versions.

@TransGirlCodes
Copy link
Author

@staticfloat

I'm going to step out on a limb and guess that you set the :cxx11 ABI constraint thinking that it would > do something like set -std=cxx11 on your compiler invocations, not realizing that it was talking about > something related but distinct, the internal layout of std::string and std::list.

That is spot on! 😆

BSG does not currently pass std::lists out of any methods or functions I know of, but it may well pass std::string as we return DNA sequences which are currently just strings (cf. the beautiful dedicated types BioJulia has :P).

Can I detect the julia tags :cxx03 or :cxx11 from my (shell) build script stage?

@staticfloat
Copy link
Member

but it may well pass std::string as we return DNA sequences which are currently just strings

Note that char * is fine; it's only std::string that is the problem.

Can I detect the julia tags :cxx03 or :cxx11 from my (shell) build script stage?

You can!

julia> using BinaryProvider; BinaryProvider.detect_cxx11_string_abi()
:cxx03

What I would do is to embed the output of that call into your bash script. Because we use raw"""...""" to define the bash script we can't interpolate directly there, but we can add a little prelude:

script_configurator = """
CXXABI=$(BinaryProvider.detect_cxx11_string_abi())
"""

script = script_configurator * raw"""
cd $WORKSPACE/srcdir
mkdir build
cd build
if [[ $CXXABI == cxx03 ]]; then
    # do something
elif [[ $CXXABI == cxx11 ]]; then
    # do something else
fi
....
"""

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

No branches or pull requests

2 participants