Skip to content

Commit cd672e4

Browse files
committed
Fix linker issues when running C++ built by the LLVM toolchain in native mode
(cherry picked from commit 95fa369)
1 parent 6c15747 commit cd672e4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

com.oracle.truffle.r.native/run/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ $(FASTR_BIN_DIR)/R: Makefile R.sh Rscript.sh Rscript_exec.sh Rclasspath.sh
8989
cp $(GNUR_HOME_BINARY)/etc/Makeconf Makeconf.etc
9090
cp $(GNUR_HOME_BINARY)/etc/javaconf $(FASTR_ETC_DIR)/javaconf
9191
cp $(GNUR_HOME_BINARY)/etc/repositories $(FASTR_ETC_DIR)/repositories
92-
cp $(GNUR_HOME_BINARY)/etc/ldpaths $(FASTR_ETC_DIR)/ldpaths
92+
# ldpaths: create two versions: ldpaths.llvm (used also as default ldpaths) and ldpaths.native
93+
# the llvm version adds the LLVM lib folder to the LD_LIBRARY_PATH
94+
sed 's!export LD_LIBRARY_PATH!LD_LIBRARY_PATH="$$\{R_HOME\}/../llvm/native/lib/:$$\{LD_LIBRARY_PATH\}"; export LD_LIBRARY_PATH!' $(GNUR_HOME_BINARY)/etc/ldpaths > $(FASTR_ETC_DIR)/ldpaths
95+
cp $(FASTR_ETC_DIR)/ldpaths $(FASTR_ETC_DIR)/ldpaths.llvm
96+
cp $(GNUR_HOME_BINARY)/etc/ldpaths $(FASTR_ETC_DIR)/ldpaths.native
9397
# the ed script adds -DFASTR to compiler options and removes JAVA related variables
9498
ed Makeconf.etc < edMakeconf.etc
9599
# Backup the current state of Makeconf.etc to allow users to switch back to the native toolchain

com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRSetToolchain.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,25 @@ public abstract class FastRSetToolchain extends RBuiltinNode.Arg1 {
5252
@Specialization
5353
protected RNull setToolchain(String name) {
5454
String srcConf;
55+
String srcLdpaths;
5556
if ("native".equals(name)) {
5657
srcConf = "Makeconf.native";
58+
srcLdpaths = "ldpaths.native";
5759
} else if ("llvm".equals(name)) {
5860
srcConf = "Makeconf.llvm";
61+
srcLdpaths = "ldpaths.llvm";
5962
} else {
6063
throw error(RError.Message.GENERIC, "Only 'native' or 'llvm' argument values accepted");
6164
}
6265
TruffleFile rHome = REnvVars.getRHomeTruffleFile(RContext.getInstance().getEnv());
6366
TruffleFile etc = rHome.resolve("etc");
64-
TruffleFile src = etc.resolve(srcConf);
65-
TruffleFile dst = etc.resolve("Makeconf");
67+
TruffleFile srcConfFile = etc.resolve(srcConf);
68+
TruffleFile dstConfFile = etc.resolve("Makeconf");
69+
TruffleFile srcLdpathsFile = etc.resolve(srcLdpaths);
70+
TruffleFile dstLdpathsFile = etc.resolve("ldpaths");
6671
try {
67-
src.copy(dst, StandardCopyOption.REPLACE_EXISTING);
72+
srcConfFile.copy(dstConfFile, StandardCopyOption.REPLACE_EXISTING);
73+
srcLdpathsFile.copy(dstLdpathsFile, StandardCopyOption.REPLACE_EXISTING);
6874
} catch (IOException e) {
6975
throw new RInternalError(String.format("Copying %s over etc/Makeconf failed", srcConf), e);
7076
}

0 commit comments

Comments
 (0)