Skip to content

Commit 359528c

Browse files
committed
Experiment with version ranges, -Zminimal-versions
This commit uses version ranges to accurately specify the minimum version of the dependencies required for this library to work. These version bounds are verified in the CI with `-Zminimal-versions` functionality of cargo which forces cargo to select the earliest versions of libraries possible.
1 parent 4ad1af8 commit 359528c

File tree

6 files changed

+101
-28
lines changed

6 files changed

+101
-28
lines changed

.github/workflows/libloading.yml

+81-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
name: Test libloading
1+
name: libloading
22

33
on:
44
push:
55
paths-ignore:
66
- '*.mkd'
77
- 'LICENSE'
8+
branches:
9+
- master
810
pull_request:
911
types: [opened, repoened, synchronize]
1012

@@ -19,6 +21,8 @@ jobs:
1921
timeout-minutes: 20
2022
steps:
2123
- uses: actions/checkout@v2
24+
- name: Set cfg(ci)
25+
run: echo "RUSTFLAGS=--cfg ci" >> $GITHUB_ENV
2226
- name: Install Rust ${{ matrix.rust_toolchain }}
2327
uses: actions-rs/toolchain@v1
2428
with:
@@ -58,6 +62,18 @@ jobs:
5862
env:
5963
RUSTDOCFLAGS: --cfg docsrs
6064
if: ${{ matrix.rust_toolchain == 'nightly' }}
65+
- name: Update Minimal Versions
66+
uses: actions-rs/cargo@v1
67+
with:
68+
command: update
69+
args: --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options
70+
if: ${{ matrix.rust_toolchain == 'nightly' }}
71+
- name: Test Minimal Versions
72+
uses: actions-rs/cargo@v1
73+
with:
74+
command: test
75+
args: --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options -- --nocapture
76+
if: ${{ matrix.rust_toolchain == 'nightly' }}
6177

6278
windows-gnu-test:
6379
runs-on: windows-latest
@@ -70,6 +86,8 @@ jobs:
7086
- i686-pc-windows-gnu
7187
steps:
7288
- uses: actions/checkout@v2
89+
- name: Set cfg(ci)
90+
run: echo "RUSTFLAGS=--cfg ci" >> $GITHUB_ENV
7391
- name: Add MSYS2 to the PATH
7492
run: echo "c:/msys64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
7593
- name: Add 32-bit mingw-w64 to the PATH
@@ -78,7 +96,7 @@ jobs:
7896
- name: Add 64-bit mingw-w64 to the PATH
7997
run: echo "c:/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
8098
if: startsWith(matrix.rust_target, 'x86_64')
81-
- name: Set TARGET variable
99+
- name: Set $TARGET
82100
run: echo "TARGET=${{ matrix.rust_target}}" | Out-File -FilePath $env:GITHUB_ENV -Append
83101
- name: Install Rust nightly
84102
uses: actions-rs/toolchain@v1
@@ -87,32 +105,59 @@ jobs:
87105
target: ${{ matrix.rust_target }}
88106
profile: minimal
89107
default: true
90-
- uses: actions-rs/cargo@v1
108+
- name: Update
109+
uses: actions-rs/cargo@v1
91110
with:
92-
command: build
93-
args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml
111+
command: update
112+
args: --manifest-path=Cargo.toml
94113
- uses: actions-rs/cargo@v1
95114
with:
96115
command: test
97116
args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml
117+
- name: Update Minimal Versions
118+
uses: actions-rs/cargo@v1
119+
with:
120+
command: update
121+
args: --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options
122+
if: ${{ matrix.rust_toolchain == 'nightly' }}
123+
- name: Test Minimal Versions
124+
uses: actions-rs/cargo@v1
125+
with:
126+
command: test
127+
args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options -- --nocapture
128+
if: ${{ matrix.rust_toolchain == 'nightly' }}
98129

99130
bare-cross-build:
100131
runs-on: ubuntu-latest
101132
strategy:
102133
fail-fast: false
103134
matrix:
104135
rust_target:
105-
# BSDs: could be tested with full system emulation
106-
# - x86_64-unknown-dragonfly
107-
# - x86_64-unknown-freebsd
136+
- aarch64-unknown-linux-gnu
137+
- arm-unknown-linux-gnueabihf
138+
- mips64-unknown-linux-gnuabi64
139+
- mips-unknown-linux-gnu
140+
- powerpc64le-unknown-linux-gnu
141+
- powerpc64-unknown-linux-gnu
142+
- powerpc-unknown-linux-gnu
143+
- riscv64gc-unknown-linux-gnu
144+
- s390x-unknown-linux-gnu
145+
- sparc64-unknown-linux-gnu
146+
- sparcv9-sun-solaris
147+
- x86_64-fuchsia
148+
- x86_64-unknown-dragonfly
149+
- x86_64-unknown-freebsd
108150
- x86_64-unknown-haiku
109-
# - x86_64-unknown-netbsd
151+
- x86_64-unknown-netbsd
110152
- x86_64-unknown-openbsd
111153
- x86_64-unknown-redox
112-
- x86_64-fuchsia
113154
timeout-minutes: 20
114155
steps:
115156
- uses: actions/checkout@v2
157+
- name: Set cfg(ci)
158+
run: echo "RUSTFLAGS=--cfg ci" >> $GITHUB_ENV
159+
- name: Set $TARGET
160+
run: echo "TARGET=${{ matrix.rust_target}}" >> $GITHUB_ENV
116161
- name: Install Rust nightly
117162
uses: actions-rs/toolchain@v1
118163
with:
@@ -132,6 +177,16 @@ jobs:
132177
with:
133178
command: build
134179
args: --target ${{ matrix.rust_target }} --manifest-path=Cargo.toml -Zbuild-std
180+
- name: Update Minimal Versions
181+
uses: actions-rs/cargo@v1
182+
with:
183+
command: update
184+
args: --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options
185+
- name: Build Minimal Versions
186+
uses: actions-rs/cargo@v1
187+
with:
188+
command: build
189+
args: --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options
135190

136191
cross-ios-build:
137192
runs-on: macos-latest
@@ -145,6 +200,10 @@ jobs:
145200
timeout-minutes: 20
146201
steps:
147202
- uses: actions/checkout@v2
203+
- name: Set cfg(ci)
204+
run: echo "RUSTFLAGS=--cfg ci" >> $GITHUB_ENV
205+
- name: Set $TARGET
206+
run: echo "TARGET=${{ matrix.rust_target}}" >> $GITHUB_ENV
148207
- name: Install Rust ${{ matrix.rust_toolchain }}
149208
uses: actions-rs/toolchain@v1
150209
with:
@@ -162,3 +221,15 @@ jobs:
162221
with:
163222
command: build
164223
args: --target=${{ matrix.rust_target }} --manifest-path=Cargo.toml
224+
- name: Update Minimal Versions
225+
uses: actions-rs/cargo@v1
226+
with:
227+
command: update
228+
args: --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options
229+
if: ${{ matrix.rust_toolchain == 'nightly' }}
230+
- name: Build Minimal Versions
231+
uses: actions-rs/cargo@v1
232+
with:
233+
command: build
234+
args: --target=${{ matrix.rust_target }} --manifest-path=Cargo.toml -Zminimal-versions -Zunstable-options
235+
if: ${{ matrix.rust_toolchain == 'nightly' }}

Cargo.toml

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@ keywords = ["dlopen", "load", "shared", "dylib"]
1414
categories = ["api-bindings"]
1515

1616
[target.'cfg(windows)'.dependencies.winapi]
17-
version = "0.3"
17+
version = ">=0.3.0, <0.4"
1818
features = [
1919
"winerror",
2020
"errhandlingapi",
2121
"libloaderapi",
2222
]
2323

2424
[target.'cfg(unix)'.dependencies.cfg-if]
25-
version = "1"
25+
version = ">=0.1.10, <2"
2626

27-
[dev-dependencies]
28-
libc = "0.2"
29-
static_assertions = "1.1"
27+
# We make some more rigorous checks in CI
28+
[target.'cfg(ci)'.dependencies]
29+
libc = ">=0.2.7, <0.3"
30+
static_assertions = ">=1.0.0, <2"
3031

3132
[package.metadata.docs.rs]
3233
all-features = true

src/changelog.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
// TODO: for the next breaking release rename `Error::LoadLibraryW` to `Error::LoadLibraryExW`.
44
// TODO: for the next breaking release use `RTLD_LAZY | RTLD_LOCAL` by default on unix.
5+
// TODO: for the next breaking release build the changelog module for cfg(docsrs) only
56

67
/// Release 0.6.5 (2020-10-23)
78
///

src/os/unix/consts.rs

+12
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ mod posix {
203203
}
204204
}
205205

206+
#[cfg(ci)]
207+
mod verify_consts {
208+
extern crate static_assertions;
209+
extern crate libc;
210+
use self::static_assertions::*;
211+
212+
const_assert_eq!(super::RTLD_LOCAL, libc::RTLD_LOCAL);
213+
const_assert_eq!(super::RTLD_GLOBAL, libc::RTLD_GLOBAL);
214+
const_assert_eq!(super::RTLD_NOW, libc::RTLD_NOW);
215+
const_assert_eq!(super::RTLD_LAZY, libc::RTLD_LAZY);
216+
}
217+
206218
// Other constants that exist but are not bound because they are platform-specific (non-posix)
207219
// extensions. Some of these constants are only relevant to `dlsym` or `dlmopen` calls.
208220
//

tests/constants.rs

-13
This file was deleted.

tests/functions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ fn make_helpers() {
2020
} else {
2121
eprintln!("WARNING: $TARGET NOT SPECIFIED! BUILDING HELPER MODULE FOR NATIVE TARGET.");
2222
}
23+
eprintln!("Building helper: {:?}", cmd);
2324
assert!(cmd
2425
.status()
2526
.expect("could not compile the test helpers!")

0 commit comments

Comments
 (0)