Skip to content

Commit

Permalink
Move compilation target from concordium_base/cargo.toml to Setup.hs
Browse files Browse the repository at this point in the history
to avoid imposing restrictions on rust dependants
  • Loading branch information
soerenbf committed Sep 18, 2024
1 parent 872e859 commit e8a9a64
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ linuxBuild True env verbosity = do
rawSystemExitWithEnv
verbosity
"cargo"
(addFeatures ["build", "--release", "--manifest-path", "rust-src/Cargo.toml", "--target", "x86_64-unknown-linux-musl"])
(addFeatures ["rustc", "--release", "--manifest-path", "rust-src/Cargo.toml", "--target", "x86_64-unknown-linux-musl", "--crate-type", "staticlib"])
(("RUSTFLAGS", "-C target-feature=-crt-static") : env)
let copyLib lib = do
let source = "../rust-src/target/x86_64-unknown-linux-musl/release/lib" ++ lib ++ ".a"
Expand All @@ -42,7 +42,7 @@ linuxBuild True env verbosity = do
mapM_ copyLib concordiumLibs
linuxBuild False env verbosity = do
noticeNoWrap verbosity "Dynamic linking."
rawSystemExitWithEnv verbosity "cargo" (addFeatures ["build", "--release", "--manifest-path", "rust-src/Cargo.toml"]) env
rawSystemExitWithEnv verbosity "cargo" (addFeatures ["rustc", "--release", "--manifest-path", "rust-src/concordium_base/Cargo.toml", "--crate-type", "cdylib"]) env
let copyLib lib = do
let source = "../rust-src/target/release/lib" ++ lib
target = "./lib/lib" ++ lib
Expand All @@ -58,7 +58,7 @@ windowsBuild env verbosity = do
rawSystemExit verbosity "cp" ["-u", "rust-src/target/release/lib" ++ lib ++ ".a", "./lib/"]
rawSystemExit verbosity "cp" ["-u", "rust-src/target/release/" ++ lib ++ ".dll", "./lib/"]
notice verbosity $ "Copied " ++ lib ++ "."
rawSystemExitWithEnv verbosity "cargo" (addFeatures ["build", "--release", "--manifest-path", "rust-src/Cargo.toml"]) env
rawSystemExitWithEnv verbosity "cargo" (addFeatures ["rustc", "--release", "--manifest-path", "rust-src/concordium_base/Cargo.toml", "--crate-type", "cdylib"]) env
notice verbosity "Copying libraries to ./lib"
mapM_ copyLib concordiumLibs

Expand All @@ -85,7 +85,7 @@ osxBuild static env verbosity = do
rawSystemExit verbosity "ln" ["-s", "-f", source, target]
noticeNoWrap verbosity $ "Linked: " ++ target ++ " -> " ++ source
noticeNoWrap verbosity $ "Removed: " ++ others
rawSystemExitWithEnv verbosity "cargo" (addFeatures ["build", "--release", "--manifest-path", "rust-src/Cargo.toml"]) env
rawSystemExitWithEnv verbosity "cargo" (addFeatures ["rustc", "--release", "--manifest-path", "rust-src/concordium_base/Cargo.toml", "--crate-type", "cdylib"]) env
notice verbosity "Linking libraries to ./lib"
mapM_ copyLib concordiumLibs

Expand Down
11 changes: 0 additions & 11 deletions mobile_wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ version = "4"
path = "../rust-src/concordium_base"
version = "4"

# Use the same optimization level for building build.rs as for the library
# itself in release mode. This is necessary because some of the dependencies
# (e.g., id) have a `cdylib/staticlib` crate-type which builds some artifacts
# even though they are not needed directly by the build script. This then leads
# to name clashes and failed compilation.
#
# Ideally we would have the crate-type of dependencies feature configurable, but
# this is not supported by Cargo at the moment.
[profile.release.build-override]
opt-level = 3

# this dependency is only needed for Android.
[target.'cfg(target_os = "android")'.dependencies]
jni = { version = "0.14.0", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion rust-src/concordium_base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ nom = "7.1.3"
rand_chacha = { version = "0.3", default-features = false, optional = true }

[lib]
crate-type = ["rlib", "staticlib", "cdylib"]
crate-type = ["lib"]

# Local dependencies
[dependencies.concordium-contracts-common]
Expand Down

0 comments on commit e8a9a64

Please sign in to comment.