src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
*** old/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java Wed Feb 8 13:49:52 2017
--- new/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java Wed Feb 8 13:49:51 2017
*** 1,7 ****
--- 1,7 ----
/*
! * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 132,144 ****
--- 132,141 ----
}
}, new Option(" --output <file> Output file name", true, "--output") {
@Override
void process(Main task, String opt, String arg) {
String name = arg;
if (name.endsWith(".so")) {
name = name.substring(0, name.length() - ".so".length());
}
task.options.outputName = name;
}
}, new Option(" --compile-commands <file> Name of file with compile commands", true, "--compile-commands") {
@Override
void process(Main task, String opt, String arg) {
*** 214,224 ****
--- 211,221 ----
public static class Options {
public List<String> files = new LinkedList<>();
public String module = null;
public String modulepath = "modules";
! public String outputName = "unnamed.so";
public String methodList;
public String classpath = ".";
/**
* We don't see scaling beyond 16 threads.
*** 315,324 ****
--- 312,336 ----
humanReadableByteCount(memusage.getCommitted()),
freeratio * 100);
}
}
+ /**
+ * Search for Visual Studio link.exe
+ * Search Order is: VS2013, VS2015, VS2012
+ */
+ private String getWindowsLinkPath() {
+ String vs2013 = "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\amd64\\link.exe";
+ String vs2015 = "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe";
+ String vs2012 = "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\bin\\amd64\\link.exe";
+
+ if (new File(vs2015).exists()) return vs2015;
+ if (new File(vs2013).exists()) return vs2013;
+ if (new File(vs2012).exists()) return vs2012;
+ return null;
+ }
+
@SuppressWarnings("try")
private void run() throws Exception {
openLog();
try {
*** 397,408 ****
--- 409,469 ----
dataBuilder = null;
binaryContainer.freeMemory();
System.gc();
}
! String objectFileName = options.outputName + ".o";
! String libraryFileName = options.outputName + ".so";
! String name = options.outputName;
! String objectFileName = name;
+
+ // [TODO] The jtregs tests expect .so extension so don't
+ // override with platform specific file extension until the
+ // tests are fixed.
+ String libraryFileName = name;
+
+ String ldCmd;
+ String osName = System.getProperty("os.name");
+
+ if (name.endsWith(".so")) {
+ objectFileName = name.substring(0, name.length() - ".so".length());
+ }
+ else if (name.endsWith(".dylib")) {
+ objectFileName = name.substring(0, name.length() - ".dylib".length());
+ }
+ else if (name.endsWith(".dll")) {
+ objectFileName = name.substring(0, name.length() - ".dll".length());
+ }
+
+ switch (osName) {
+ case "Linux":
+ // libraryFileName = options.outputName + ".so";
+ objectFileName = objectFileName + ".o";
+ ldCmd = "ld -shared -z noexecstack -o " + libraryFileName + " " + objectFileName;
+ break;
+ case "SunOS":
+ // libraryFileName = options.outputName + ".so";
+ objectFileName = objectFileName + ".o";
+ ldCmd = "ld -shared -o " + libraryFileName + " " + objectFileName;
+ break;
+ case "Mac OS X":
+ // libraryFileName = options.outputName + ".dylib";
+ objectFileName = objectFileName + ".o";
+ ldCmd = "ld -dylib -o " + libraryFileName + " " + objectFileName;
+ break;
+ default:
+ if (osName.startsWith("Windows")) {
+ // libraryFileName = options.outputName + ".dll";
+ objectFileName = objectFileName + ".obj";
+ String linkpath = getWindowsLinkPath();
+ if (linkpath == null) {
+ throw new InternalError("Can't locate Microsoft Visual Studio amd64 link.exe");
+ }
+ ldCmd = linkpath + " /DLL /OPT:NOREF /NOLOGO /NOENTRY" + " /OUT:" + libraryFileName + " " + objectFileName;
+ break;
+ }
+ else
+ throw new InternalError("Unsupported platform: " + osName);
+ }
try (Timer t = new Timer(this, "Creating binary: " + objectFileName)) {
binaryContainer.createBinary(objectFileName, JVM_VERSION);
}
*** 412,422 ****
--- 473,483 ----
binaryContainer = null;
System.gc();
}
try (Timer t = new Timer(this, "Creating shared library: " + libraryFileName)) {
! Process p = Runtime.getRuntime().exec("ld -shared -z noexecstack -o " + libraryFileName + " " + objectFileName);
! Process p = Runtime.getRuntime().exec(ldCmd);
final int exitCode = p.waitFor();
if (exitCode != 0) {
InputStream stderr = p.getErrorStream();
BufferedReader br = new BufferedReader(new InputStreamReader(stderr));
Stream<String> lines = br.lines();
*** 430,440 ****
--- 491,501 ----
throw new InternalError("Failed to delete " + objectFileName + " file");
}
}
// Make non-executable for all.
File libFile = new File(libraryFileName);
! if (libFile.exists() && !osName.startsWith("Windows")) {
if (!libFile.setExecutable(false, false)) {
throw new InternalError("Failed to change attribute for " + libraryFileName + " file");
}
}
}
src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/Main.java
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File