For information on using this system, please visit this page.

Bug 17130 - R CMD SHLIB fails when exported symbol name conflicts w/ ld keyword
Summary: R CMD SHLIB fails when exported symbol name conflicts w/ ld keyword
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Windows GUI / Window specific (show other bugs)
Version: R 3.3.*
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 normal
Assignee: R-core
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-12 16:24 UTC by Kyle Baron
Modified: 2016-08-12 16:47 UTC (History)
2 users (show)

See Also:


Attachments
Patch to put double-quotes around symbol names in tmp.def (938 bytes, patch)
2016-08-12 16:24 UTC, Kyle Baron
Details | Diff
R test code (463 bytes, text/plain)
2016-08-12 16:26 UTC, Kyle Baron
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle Baron 2016-08-12 16:24:47 UTC
Created attachment 2139 [details]
Patch to put double-quotes around symbol names in tmp.def

For example: BASE is a keyword so building a shared object on Windows
with a function called BASE fails:


code <- '
void BASE(int *nin, double *x) {
  int n = nin[0];
  int i;
  for (i=0; i<n; i++) x[i] = x[i] * x[i];
}
'
writeLines(code,"test_base.c")
system("R CMD SHLIB test_base.c")

The output is:
 c:/Rtools/mingw_64/bin/gcc  -I"C:/PROGRA~1/R/R-33~1.1/include"
 -DNDEBUG     -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall
 -std=gnu99 -mtune=core2 -c test_base.c -o test_base.o
 c:/Rtools/mingw_64/bin/gcc -shared -s -static-libgcc -o test_base.dll
 tmp.def test_base.o -Ld:/Compiler/gcc-4.9.3/local330/lib/x64
 -Ld:/Compiler/gcc-4.9.3/local330/lib -LC:/PROGRA~1/R/R-33~1.1/bin/x64
 -lR

 C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:
 tmp.def:3: syntax error
 C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:tmp.def:
 file format not recognized; treating as linker script
 C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe:tmp.def:2:
 syntax error collect2.exe: error: ld returned 1 exit status


In my testing, this happens with other ld keywords (LIBRARY, EXPORTS, NAME, SHARED, etc).

Putting double-quotes around symbol names under EXPORTS in the tmp.def
file created by winshlib.mk appeared to resolve the symbol name / keyword
conflict.

Attaching a proposed patch for share/make/winshlib.mk and R script with test case.

My Windows testing done on:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

Reference: https://stat.ethz.ch/pipermail/r-devel/2016-August/072973.html
Comment 1 Kyle Baron 2016-08-12 16:26:58 UTC
Created attachment 2140 [details]
R test code
Comment 2 Duncan Murdoch 2016-08-12 16:47:19 UTC
Thanks.  I'll put your patch into R-devel and R-patched.