[Rd] Quote symbol names under EXPORTS in tmp.def on Windows
Kyle Baron
kyleb at metrumrg.com
Sun Aug 7 06:51:53 CEST 2016
I originally posted on this topic on a different thread:
https://stat.ethz.ch/pipermail/r-devel/2016-August/072938.html
These sources suggested that a safe practice might be to put double
quotes around symbol names in EXPORTS in case the symbol name is the
same as a linker keyword:
- https://sourceware.org/binutils/docs/ld/Symbols.html#Symbols
- https://msdn.microsoft.com/en-us/library/163abkbh.aspx
I wasn't sure how that related specifically to what Rtools is using,
but when I made the following change to winshlib.mk (double quotes
around symbol names in tmp.def), I was able to compile code without
issue and get symbols like BASE (or other keywords) exported.
Kyle
## ${R_HOME}/share/make/winshlib.mk
6a7,8
> ADDQU = 's/[^ ][^ ]*/"&"/g'
>
17c19
< $(NM) $^ | $(SED) -n $(SYMPAT) $(NM_FILTER) >> tmp.def; \
---
> $(NM) $^ | $(SED) -n $(SYMPAT) $(NM_FILTER) | $(SED) $(ADDQU) >> tmp.def; \
code <- '
void BASE(int *nin, double *x) {
int n = nin[0];
for (int i=0; i<n; i++) x[i] = x[i] * x[i];
}
void rd(int *nin, double *x) {
int n = nin[0];
for (int i=0; i<n; i++) x[i] = x[i] * x[i];
}
double EXPORTS = 2.1;
int LIBRARY = 3;
'
writeLines(code, "src1.c")
system("R CMD SHLIB src1.c")
dyn.load("src1.dll")
is.loaded("EXPORTS",PACKAGE="src1")
is.loaded("BASE",PACKAGE="src1")
is.loaded("rd",PACKAGE="src1")
dyn.unload("src1.dll")
--
Kyle Baron
Metrum Research Group
More information about the R-devel
mailing list