Skip to content

Commit 579a2eb

Browse files
committed
cmake: Read RUSTFLAGS from environment and propagate correctly
1 parent 8d25a7e commit 579a2eb

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.github/workflows/ci-common.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
container-version:
1111
required: true
1212
type: string
13+
env:
14+
RUSTFLAGS: "-Dwarnings"
15+
CFLAGS: "-Werror"
1316

1417
jobs:
1518
check-sigs:
@@ -54,8 +57,6 @@ jobs:
5457
runs-on: ubuntu-22.04
5558
container:
5659
image: ${{ inputs.container-repo }}:${{ inputs.container-version }}
57-
env:
58-
RUSTFLAGS: "-Dwarnings"
5960
steps:
6061
- name: Clone the repo
6162
uses: actions/checkout@v4
@@ -81,8 +82,6 @@ jobs:
8182
runs-on: ubuntu-22.04
8283
container:
8384
image: ${{ inputs.container-repo }}:${{ inputs.container-version }}
84-
env:
85-
RUSTFLAGS: "-Dwarnings"
8685
steps:
8786
- name: Clone the repo
8887
uses: actions/checkout@v4
@@ -170,8 +169,6 @@ jobs:
170169
runs-on: ubuntu-22.04
171170
container:
172171
image: ${{ inputs.container-repo }}:${{ inputs.container-version }}
173-
env:
174-
RUSTFLAGS: "-Dwarnings"
175172
steps:
176173
- name: Clone the repo
177174
uses: actions/checkout@v4

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG")
243243
set(CMAKE_C_FLAGS_DEBUG "-Os -ggdb")
244244
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -ggdb -DNDEBUG")
245245

246+
if(DEFINED ENV{RUSTFLAGS})
247+
set(RUSTFLAGS $ENV{RUSTFLAGS})
248+
endif()
249+
246250
#-----------------------------------------------------------------------------
247251
# Print system information and build options
248252

@@ -270,6 +274,7 @@ message(STATUS "Compiler cache: ${CMAKE_C_COMPILER_LAUNCHER}")
270274
message(STATUS "Linker: ${CMAKE_LINKER}")
271275
message(STATUS "Archiver: ${CMAKE_AR}")
272276
message(STATUS "Default CFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
277+
message(STATUS "Default RUSTFLAGS: ${RUSTFLAGS}")
273278
message(STATUS "Default EXE LDFLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
274279
message(STATUS " - Options -")
275280
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ else()
230230
set(RUST_PROFILE "release")
231231
set(RUST_CARGO_FLAGS "--release")
232232
# For binary reproducibility, strip path prefixes that can be different depending on environment (e.g. /home/<user>, etc.).
233-
set(RUSTFLAGS "--remap-path-prefix=${CMAKE_CURRENT_SOURCE_DIR}/rust=src --remap-path-prefix=$ENV{HOME}=")
233+
string(APPEND RUSTFLAGS " --remap-path-prefix=${CMAKE_CURRENT_SOURCE_DIR}/rust=src --remap-path-prefix=$ENV{HOME}=")
234234
endif()
235235

236236
# Use libsecp256k1 that we link ourselves.
237237
# See https://github.com/rust-bitcoin/rust-secp256k1/tree/7c8270a8506e31731e540fab7ee1abde1f48314e/secp256k1-sys#linking-to-external-symbols
238-
set(RUSTFLAGS "${RUSTFLAGS} --cfg=rust_secp_no_symbol_renaming")
238+
string(APPEND RUSTFLAGS " --cfg=rust_secp_no_symbol_renaming")
239239

240240
if(CMAKE_CROSSCOMPILING)
241241
set(RUST_TARGET_ARCH thumbv7em-none-eabi)

0 commit comments

Comments
 (0)