Skip to content

Commit 69a94ea

Browse files
author
Cheng Jin
committed
Update java code for RISC-V (src)
The changes are to modify the java code in the src directory to avoid the timeout issue in the native compilation on RISC-V. Issue: ibmruntimes#218 Signed-off-by: Cheng Jin <[email protected]>
1 parent 642d340 commit 69a94ea

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* or visit www.oracle.com if you need additional information or have any
2323
* questions.
2424
*/
25+
/*
26+
* ===========================================================================
27+
* (c) Copyright IBM Corp. 2019, 2019 All Rights Reserved
28+
* ===========================================================================
29+
*/
2530

2631
package com.sun.tools.sjavac.client;
2732

@@ -84,6 +89,8 @@ public class SjavacClient implements Sjavac {
8489

8590
// Store the server conf settings here.
8691
private final String settings;
92+
93+
private boolean isRiscv = System.getProperty("os.arch").toLowerCase().contains("riscv");
8794

8895
public SjavacClient(Options options) {
8996
String tmpServerConf = options.getServerConf();
@@ -183,10 +190,15 @@ private Socket tryConnect() throws IOException, InterruptedException {
183190
try {
184191
return makeConnectionAttempt();
185192
} catch (IOException ex) {
186-
Log.error("Connection attempt failed: " + ex.getMessage());
187-
if (attempt >= MAX_CONNECT_ATTEMPTS) {
188-
Log.error("Giving up");
189-
throw new IOException("Could not connect to server", ex);
193+
/* Keep trying to connect as the native compilation with a non-JIT cross build
194+
* on Linux/RISCV is extremely slow.
195+
*/
196+
if (!isRiscv) {
197+
Log.error("Connection attempt failed: " + ex.getMessage());
198+
if (attempt >= MAX_CONNECT_ATTEMPTS) {
199+
Log.error("Giving up");
200+
throw new IOException("Could not connect to server", ex);
201+
}
190202
}
191203
}
192204
Thread.sleep(WAIT_BETWEEN_CONNECT_ATTEMPTS);

src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/PortFile.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
* or visit www.oracle.com if you need additional information or have any
2323
* questions.
2424
*/
25+
/*
26+
* ===========================================================================
27+
* (c) Copyright IBM Corp. 2019, 2019 All Rights Reserved
28+
* ===========================================================================
29+
*/
2530

2631
package com.sun.tools.sjavac.server;
2732

@@ -76,6 +81,7 @@ public class PortFile {
7681
private long serverCookie;
7782
private int myServerPort;
7883
private long myServerCookie;
84+
private boolean isRiscv = System.getProperty("os.arch").toLowerCase().contains("riscv");
7985

8086
/**
8187
* Create a new portfile.
@@ -247,7 +253,11 @@ public void waitForValidValues() throws IOException, InterruptedException {
247253
Log.debug("Valid port file values found after " + (System.currentTimeMillis() - startTime) + " ms");
248254
return;
249255
}
250-
if (System.currentTimeMillis() > timeout) {
256+
257+
/* Keep waiting for port file values as the native compilation with a non-JIT cross build
258+
* on Linux/RISCV is extremely slow.
259+
*/
260+
if (!isRiscv && (System.currentTimeMillis() > timeout)) {
251261
break;
252262
}
253263
Thread.sleep(MS_BETWEEN_ATTEMPTS);

0 commit comments

Comments
 (0)