Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Commit

Permalink
Support R 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yutannihilation committed Apr 29, 2022
1 parent 607ec24 commit 392fe5b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
4 changes: 4 additions & 0 deletions configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ case $ret in
exit $ret
esac

# To address the change of the toolchain on R 4.2
BEFORE_CARGO_BUILD="${BEFORE_CARGO_BUILD}"' export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$(CARGO_LINKER)" \&\&'
BEFORE_CARGO_BUILD="${BEFORE_CARGO_BUILD}"' export LIBRARY_PATH="$${LIBRARY_PATH};$(CURDIR)/$(LIBDIR)/libgcc_mock" \&\&'

# If it's on CRAN, a package is not allowed to write in any other place than the
# temporary directory on installation. So, we need to tweak Makevars to make the
# compilation happen only within the package directory (i.e. `$(PWD)`).
Expand Down
2 changes: 2 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.so
*.dll
target

/rust/.vscode/settings.json
10 changes: 10 additions & 0 deletions src/Makevars.ucrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Use GNU toolchain for R >= 4.2
TOOLCHAIN = stable-gnu


# Rtools42 doesn't have the linker in the location that cargo expects, so we
# need to overwrite it via configuration.
CARGO_LINKER = x86_64-w64-mingw32.static.posix-gcc.exe


include Makevars.win
10 changes: 9 additions & 1 deletion src/Makevars.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# available when configure.win is used. So, R_ARCH is chosen here.
TARGET = $(subst /x64,x86_64,$(subst /i386,i686,$(R_ARCH)))-pc-windows-gnu

TOOLCHAIN = stable-gnu
# This is provided in Makevars.ucrt for R >= 4.2
TOOLCHAIN ?= stable-msvc

LIBDIR = ./rust/target/$(TARGET)/release

Expand All @@ -16,6 +17,13 @@ all: C_clean
$(SHLIB): $(STATLIB)

$(STATLIB):
mkdir -p $(LIBDIR)/libgcc_mock
cd $(LIBDIR)/libgcc_mock && \
touch gcc_mock.c && \
gcc -c gcc_mock.c -o gcc_mock.o && \
ar -r libgcc_eh.a gcc_mock.o && \
cp libgcc_eh.a libgcc_s.a

@BEFORE_CARGO_BUILD@ cargo +$(TOOLCHAIN) build --target=$(TARGET) --lib --release --manifest-path=./rust/Cargo.toml
@AFTER_CARGO_BUILD@

Expand Down
8 changes: 4 additions & 4 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
crate-type = ["staticlib"]

[dependencies]
extendr-api = { git = "https://github.com/yutannihilation/extendr", branch = "feature/graphics-feature-gate", features = ["graphics"] }
extendr-api = { git = "https://github.com/extendr/extendr", features = ["graphics"] }

wgpu = { git = "https://github.com/gfx-rs/wgpu/" }
# bytemuck converts Rust data into Plain Old Data, which can be passed to WebGPU
Expand Down

0 comments on commit 392fe5b

Please sign in to comment.