Skip to content

Commit f411843

Browse files
Optimize R (#3841)
* Optimize R * Build R shared lib
1 parent e68b3cf commit f411843

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

recipes/recipes_emscripten/r-base/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pushd _build_wasm
9797
--prefix=$PREFIX \
9898
--build="x86_64-conda-linux-gnu" \
9999
--host="wasm32-unknown-emscripten" \
100+
--enable-R-shlib \
100101
$CONFIG_ARGS
101102

102103
emmake make -j${CPU_COUNT}

recipes/recipes_emscripten/r-base/config.site

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#! /bin/sh
22

3+
# Optimization
4+
OPT_FLAG="-Oz"
5+
36
### This file is part of R.
47
###
58
### R is free software; you can redistribute it and/or modify it under
@@ -53,7 +56,7 @@ CC=emcc
5356
## and '-g' in all other cases except icc (for which see R-admin.html).
5457
## Be wary of aggressive settings such as -ffast-math, -Ofast and
5558
## -Werror (which is likely to cause configure to fail).
56-
CFLAGS="-fPIC -fwasm-exceptions -sSUPPORT_LONGJMP=wasm"
59+
CFLAGS="${OPT_FLAG} -fPIC -fwasm-exceptions -sSUPPORT_LONGJMP=wasm"
5760

5861
## Ditto for a compiler that supports C17 features and not C23 ones.
5962
## For example, 'CC17=gcc -std=gnu17', omit -Wstrict-prototypes from C17FLAGS.
@@ -110,7 +113,7 @@ CFLAGS="-fPIC -fwasm-exceptions -sSUPPORT_LONGJMP=wasm"
110113
## options (such as defines) for the C preprocessor and compiler.
111114
## If unset defaults to '-I/usr/local/include', with '-I/sw/include'
112115
## prepended on systems using Fink with root '/sw'.
113-
CPPFLAGS="-fwasm-exceptions -sSUPPORT_LONGJMP=wasm -I$PREFIX/include"
116+
CPPFLAGS="${OPT_FLAG} -fwasm-exceptions -sSUPPORT_LONGJMP=wasm -I$PREFIX/include"
114117

115118
## The command which runs the Fortran compiler.
116119
## Used for both fixed-form and free-form Fortran
@@ -119,7 +122,7 @@ FC=flang-new
119122

120123
## Options for the Fortran compiler.
121124
## Use this to specify compilation flags for fixed-form Fortran.
122-
FFLAGS="-g --target=wasm32-unknown-emscripten -fPIC"
125+
FFLAGS="-g --target=wasm32-unknown-emscripten -fPIC -O2"
123126
## Ditto for free-form Fortran.
124127
## FCFLAGS=
125128
## If just one of these is set, it is used for both.
@@ -166,8 +169,7 @@ FCLIBS="-lFortranRuntime"
166169
## is given.
167170
## For example, one can set flags for profiling here.
168171
## NOTE: These apply to R.bin
169-
MAIN_LDFLAGS="-sWASM_BIGINT \
170-
-sMAIN_MODULE=1 \
172+
MAIN_LDFLAGS="-sMAIN_MODULE=1 \
171173
-sSTACK_SIZE=5MB \
172174
-sALLOW_MEMORY_GROWTH=1 \
173175
-sEXPORTED_RUNTIME_METHODS=callMain,FS,ENV,getEnvStrings,TTY \
@@ -208,7 +210,7 @@ FPICFLAGS="-fPIC"
208210
## On macOS, the default is
209211
## -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup
210212
## For other platforms, see configure.ac
211-
SHLIB_LDFLAGS="-sSIDE_MODULE=1 -sWASM_BIGINT -fwasm-exceptions -sSUPPORT_LONGJMP=wasm"
213+
SHLIB_LDFLAGS="${OPT_FLAG} -sSIDE_MODULE=1 -fwasm-exceptions -sSUPPORT_LONGJMP=wasm"
212214

213215
## ditto for a dynamic library: DYLIB_LDFLAGS defaults to SHLIB_LDFLAGS
214216
## DYLIB_LD=
@@ -226,7 +228,7 @@ SHLIB_LDFLAGS="-sSIDE_MODULE=1 -sWASM_BIGINT -fwasm-exceptions -sSUPPORT_LONGJMP
226228
## on macOS systems using Fink with root '/sw'.
227229
## On some Linux 64-bit systems its default is -L/usr/local/lib64.
228230
## If LIBnn is set it defaults to -L/usr/local/$LIBnn.
229-
LDFLAGS="-L$PREFIX/lib -sWASM_BIGINT"
231+
LDFLAGS="${OPT_FLAG} -L$PREFIX/lib"
230232

231233

232234
## The command which runs the C++ compiler.
@@ -239,7 +241,7 @@ LDFLAGS="-L$PREFIX/lib -sWASM_BIGINT"
239241
CXX=em++
240242

241243
## Options for the C++ compiler.
242-
CXXFLAGS="-sWASM_BIGINT"
244+
CXXFLAGS="${OPT_FLAG}"
243245

244246
## Any special flags which must be used when compiling C++ code to be
245247
## turned into a shared object. If this variable is left unspecified
@@ -260,7 +262,7 @@ CXXPICFLAGS="-fPIC"
260262
## containing object files from a C++ compiler. This is usually
261263
## automatically detected by configure, and anything set here will be in
262264
## addition unless SHLIB_CXXLD is given.
263-
SHLIB_CXXLDFLAGS="-sSIDE_MODULE=1"
265+
SHLIB_CXXLDFLAGS="${OPT_FLAG} -sSIDE_MODULE=1"
264266

265267
## Not used by R but configure can fail to find it, so set to
266268
## "$CXX -E" if it does.

recipes/recipes_emscripten/r-base/recipe.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ source:
2626
- patches/0013-Use-source-files-when-installing.patch
2727

2828
build:
29-
number: 0
29+
number: 1
3030

3131
requirements:
3232
build:
@@ -65,7 +65,7 @@ requirements:
6565
tests:
6666
- package_contents:
6767
lib:
68-
- R/lib/libR.a
68+
- R/lib/libR.so
6969
- R/lib/libRblas.so
7070
- R/lib/libRlapack.so
7171
- R/library/grDevices/libs/cairo.so

0 commit comments

Comments
 (0)