Skip to content

Commit 608f5ab

Browse files
author
Cheng Jin
committed
Update configure scripts for RISC-V (src)
The changes are to modify the java code in the src directory to disable compiling AWT related library in cross-compilation for RISC-V. Issue: ibmruntimes#218 Signed-off-by: Cheng Jin <[email protected]>
1 parent 642d340 commit 608f5ab

File tree

6 files changed

+60
-6
lines changed

6 files changed

+60
-6
lines changed

src/java.desktop/share/native/common/awt/utility/rect.c

+9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
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+
*/
30+
31+
#ifndef RISCV64_CROSS
2532

2633
#include "utility/rect.h"
2734

@@ -100,3 +107,5 @@ int BitmapToYXBandedRectangles(int bitsPerPixel, int width, int height, unsigned
100107
#if defined(__cplusplus)
101108
}
102109
#endif
110+
111+
#endif /* !RISCV64_CROSS */

src/java.desktop/share/native/libawt/java2d/pipe/Region.c

+8
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
#include <stdlib.h>
2732

@@ -222,6 +227,7 @@ Region_EndIteration(JNIEnv *env, RegionData *pRgnInfo)
222227
}
223228
}
224229

230+
#ifndef RISCV64_CROSS
225231
/*
226232
* The code was extracted from
227233
* src/solaris/native/sun/java2d/x11/X11SurfaceData.c
@@ -282,3 +288,5 @@ RegionToYXBandedRectangles(JNIEnv *env,
282288

283289
return numrects;
284290
}
291+
292+
#endif /* !RISCV64_CROSS */

src/java.desktop/share/native/libawt/java2d/pipe/Region.h

+7-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
#ifndef _Included_Region
2732
#define _Included_Region
@@ -198,7 +203,7 @@ Region_NextIteration(RegionData *pRgnInfo, SurfaceDataBounds *pSpan);
198203
JNIEXPORT void JNICALL
199204
Region_EndIteration(JNIEnv *env, RegionData *pRgnInfo);
200205

201-
206+
#ifndef RISCV64_CROSS
202207
/*
203208
* Converts a sun.java2d.pipe.Region object to a list of
204209
* rectangles using platform specific native data representation
@@ -210,6 +215,7 @@ RegionToYXBandedRectangles(JNIEnv *env,
210215
jint x1, jint y1, jint x2, jint y2, jobject region,
211216
RECT_T ** pRect, unsigned int initialBufferSize);
212217

218+
#endif /* !RISCV64_CROSS */
213219

214220
#ifdef __cplusplus
215221
};

src/java.desktop/unix/native/common/awt/utility/rect.h

+9
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,22 @@
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
/* platform-dependent definitions */
2732

2833
#ifndef _AWT_RECT_H
2934
#define _AWT_RECT_H
3035

3136
#ifndef MACOSX
37+
#ifndef RISCV64_CROSS
3238
#include <X11/Xlib.h>
3339
typedef XRectangle RECT_T;
40+
#endif /* !RISCV64_CROSS */
3441
#else
3542
// OSX still needs this for BitmapToYXBandedRectangles
3643
typedef struct {
@@ -57,8 +64,10 @@ typedef struct {
5764
extern "C" {
5865
#endif
5966

67+
#ifndef RISCV64_CROSS
6068
int BitmapToYXBandedRectangles(int bitsPerPixel, int width, int height,
6169
unsigned char * buf, RECT_T * outBuf);
70+
#endif /* !RISCV64_CROSS */
6271

6372
#if defined(__cplusplus)
6473
}

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)