Skip to content

Commit 4560e45

Browse files
committed
[GR-40042] Don't assume current arch is equal to target arch in LLVM toolchain wrappers.
PullRequest: graal/12331
2 parents 846bff6 + 5c6e460 commit 4560e45

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

sulong/projects/com.oracle.truffle.llvm.toolchain.launchers/src/com/oracle/truffle/llvm/toolchain/launchers/common/ClangLike.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2022, Oracle and/or its affiliates.
33
*
44
* All rights reserved.
55
*
@@ -34,15 +34,15 @@
3434
public class ClangLike extends ClangLikeBase {
3535

3636
public static void runClangXX(String[] args) {
37-
new ClangLike(args, true, OS.getCurrent(), NATIVE_PLATFORM).run();
37+
new ClangLike(args, true, OS.getCurrent(), Arch.getCurrent(), NATIVE_PLATFORM).run();
3838
}
3939

4040
public static void runClang(String[] args) {
41-
new ClangLike(args, false, OS.getCurrent(), NATIVE_PLATFORM).run();
41+
new ClangLike(args, false, OS.getCurrent(), Arch.getCurrent(), NATIVE_PLATFORM).run();
4242
}
4343

44-
protected ClangLike(String[] args, boolean cxx, OS os, String platform) {
45-
super(args, cxx, os, platform);
44+
protected ClangLike(String[] args, boolean cxx, OS os, Arch arch, String platform) {
45+
super(args, cxx, os, arch, platform);
4646
}
4747

4848
@Override

sulong/projects/com.oracle.truffle.llvm.toolchain.launchers/src/com/oracle/truffle/llvm/toolchain/launchers/common/ClangLikeBase.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ public abstract class ClangLikeBase extends Driver {
5656
protected final boolean cxx;
5757
protected final boolean earlyExit;
5858
protected final OS os;
59+
protected final Arch arch;
5960
protected final String[] args;
6061
protected final String platform;
6162
protected final int outputFlagPos;
6263
protected final boolean nostdincxx;
6364

64-
protected ClangLikeBase(String[] args, boolean cxx, OS os, String platform) {
65+
protected ClangLikeBase(String[] args, boolean cxx, OS os, Arch arch, String platform) {
6566
super(cxx ? "clang++" : "clang");
6667
this.cxx = cxx;
6768
this.os = os;
69+
this.arch = arch;
6870
this.platform = platform;
6971
boolean mayHaveInputFiles = false;
7072
boolean mayBeLinkerInvocation = true;
@@ -177,8 +179,8 @@ protected void getCompilerArgs(List<String> sulongArgs) {
177179
sulongArgs.addAll(getVectorInstructionSetFlags());
178180
}
179181

180-
private static List<String> getVectorInstructionSetFlags() {
181-
switch (Arch.getCurrent()) {
182+
private List<String> getVectorInstructionSetFlags() {
183+
switch (arch) {
182184
case X86_64:
183185
return Arrays.asList("-mno-sse3", "-mno-avx");
184186
case AARCH_64:

sulong/projects/com.oracle.truffle.llvm.toolchain.launchers/src/com/oracle/truffle/llvm/toolchain/launchers/common/Driver.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,11 @@ public static Arch getCurrent() {
116116
}
117117
}
118118

119-
private static final boolean hasJreDir = System.getProperty("java.specification.version").startsWith("1.");
120-
121119
private static Path getRuntimeDir() {
122120
Path runtimeDir = HomeFinder.getInstance().getHomeFolder();
123121
if (runtimeDir == null) {
124122
throw new IllegalStateException("Could not find GraalVM home");
125123
}
126-
if (hasJreDir) {
127-
runtimeDir = runtimeDir.resolve("jre");
128-
}
129124
return runtimeDir;
130125
}
131126

sulong/projects/com.oracle.truffle.llvm.toolchain.launchers/src/com/oracle/truffle/llvm/toolchain/launchers/darwin/DarwinClangLike.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2019, Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2022, Oracle and/or its affiliates.
33
*
44
* All rights reserved.
55
*
@@ -35,16 +35,16 @@
3535

3636
public class DarwinClangLike extends ClangLike {
3737

38-
protected DarwinClangLike(String[] args, boolean cxx, OS os, String platform) {
39-
super(args, cxx, os, platform);
38+
protected DarwinClangLike(String[] args, boolean cxx, OS os, Arch arch, String platform) {
39+
super(args, cxx, os, arch, platform);
4040
}
4141

4242
public static void runClangXX(String[] args) {
43-
new DarwinClangLike(args, true, OS.getCurrent(), NATIVE_PLATFORM).run();
43+
new DarwinClangLike(args, true, OS.getCurrent(), Arch.getCurrent(), NATIVE_PLATFORM).run();
4444
}
4545

4646
public static void runClang(String[] args) {
47-
new DarwinClangLike(args, false, OS.getCurrent(), NATIVE_PLATFORM).run();
47+
new DarwinClangLike(args, false, OS.getCurrent(), Arch.getCurrent(), NATIVE_PLATFORM).run();
4848
}
4949

5050
@Override

0 commit comments

Comments
 (0)