Closed ghost closed 3 years ago
Hi, the compile_ll.sh
script is not super well tested and the issues here are due to bugs in that script. It's somewhat sensitive to which directory you run it from and isn't entirely portable across shells. Also I think it's not parsing the arguments correctly and it thinks they're all one big file name.
You can always manually run the appropriate clang
command directly, which in the compile script is:
"$CLANG" -Wno-override-module -lgc -g -L"$BASE_DIR"/runtime/out -ljvm -L"$JDK"/out -ljdk -Wl,-rpath,"$JDK7_LIB" -Wl,-rpath,"$JDK"/out -Wl,-rpa\
th,"$BASE_DIR"/runtime/out -rdynamic -o "$OBJ_NAME" "$ARGS"
You just have to replace the variables with the appropriate values.
I'll mark this as a bug to track the issue in compile_ll.sh
Yes the master branch has the bug fix for the compile script (in addition to Andrew's fix there were some incorrect path names).
I tested it on the application you provided and there were some other compilation issues, which I'll use this issue to track. Specifically JLang wasn't compiling the java.util.Scanner
or java.util.sql.Date
classes correctly and thus they weren't available to link at link time.
I'll look into what the underlying cause for that is - but it is unrelated to the tooling at least now.
Hi Drew,
Thank you for your response.
Dropping the quotations (Andrew's fix) solved the no such file or directory
problem.
As you said, there were some minor issues with the compile script, and I had fixed them earlier.
I tried to manually use the commands to compile before, but I got the java.util.Scanner
- and java.util.sql.Date
-related errors, too:
$ find out -name "*.ll" | xargs ../bin/compile_ll.sh AppExec
/tmp/ThriftyRentSystem-96c4b9.o: In function `Polyglot_ThriftyRentSystem_run__':
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:35: undefined reference to `Polyglot_java_util_Scanner_cdv'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:35: undefined reference to `Polyglot_java_util_Scanner_Scanner__Ljava_io_InputStream_2'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:36: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:58: undefined reference to `Polyglot_java_util_Scanner_close__'
/tmp/ThriftyRentSystem-96c4b9.o: In function `Polyglot_ThriftyRentSystem_add__Ljava_util_Scanner_2':
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:79: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:83: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:86: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:90: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:94: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/tmp/ThriftyRentSystem-96c4b9.o:/home/vagrant/JLang/app/src/ThriftyRentSystem.java:96: more undefined references to `Polyglot_java_util_Scanner_nextLine__' follow
/tmp/ThriftyRentSystem-96c4b9.o: In function `Polyglot_ThriftyRentSystem_add__Ljava_util_Scanner_2':
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:141: undefined reference to `Polyglot_java_util_Scanner_next__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:146: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/tmp/ThriftyRentSystem-96c4b9.o: In function `Polyglot_ThriftyRentSystem_rent__Ljava_util_Scanner_2':
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:169: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:234: undefined reference to `Polyglot_java_util_Scanner_next__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:236: undefined reference to `Polyglot_java_util_Scanner_next__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:241: undefined reference to `Polyglot_java_util_Scanner_nextLine__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:246: undefined reference to `Polyglot_java_util_Scanner_nextInt__'
/tmp/ThriftyRentSystem-96c4b9.o: In function `Polyglot_ThriftyRentSystem_returnCar__Ljava_util_Scanner_2':
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:287: undefined reference to `Polyglot_java_util_Scanner_next__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:308: undefined reference to `Polyglot_java_util_Scanner_next__'
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:336: undefined reference to `Polyglot_java_util_Scanner_next__'
/tmp/ThriftyRentSystem-96c4b9.o: In function `Polyglot_ThriftyRentSystem_vehicleMaintenance__Ljava_util_Scanner_2':
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:366: undefined reference to `Polyglot_java_util_Scanner_next__'
/tmp/ThriftyRentSystem-96c4b9.o: In function `Polyglot_ThriftyRentSystem_completeMaintenance__Ljava_util_Scanner_2':
/home/vagrant/JLang/app/src/ThriftyRentSystem.java:432: undefined reference to `Polyglot_java_util_Scanner_next__'
/tmp/ThriftyRentSystem-96c4b9.o:/home/vagrant/JLang/app/src/ThriftyRentSystem.java:450: more undefined references to `Polyglot_java_util_Scanner_next__' follow
/tmp/ThriftyRentSystem-96c4b9.o:(.data+0x1db8): undefined reference to `Polyglot_java_util_Scanner_class'
/tmp/ThriftyRentSystem-96c4b9.o:(.data+0x1dc0): undefined reference to `Polyglot_java_util_Scanner_class'
/tmp/ThriftyRentSystem-96c4b9.o:(.data+0x1dc8): undefined reference to `Polyglot_java_util_Scanner_class'
/tmp/ThriftyRentSystem-96c4b9.o:(.data+0x1dd0): undefined reference to `Polyglot_java_util_Scanner_class'
/tmp/ThriftyRentSystem-96c4b9.o:(.data+0x1dd8): undefined reference to `Polyglot_java_util_Scanner_class'
/tmp/DateTime-6d815f.o: In function `Polyglot_DateTime_getEightDigitDate__':
/home/vagrant/JLang/app/src/DateTime.java:58: undefined reference to `Polyglot_java_sql_Date_cdv'
/home/vagrant/JLang/app/src/DateTime.java:58: undefined reference to `Polyglot_java_sql_Date_Date(__complex)'
/tmp/DateTime-6d815f.o: In function `Polyglot_DateTime_getFormattedDate__':
/home/vagrant/JLang/app/src/DateTime.java:50: undefined reference to `Polyglot_java_sql_Date_cdv'
/home/vagrant/JLang/app/src/DateTime.java:50: undefined reference to `Polyglot_java_sql_Date_Date(__complex)'
/tmp/DateTime-6d815f.o: In function `Polyglot_DateTime_getCurrentTime__':
/home/vagrant/JLang/app/src/DateTime.java:43: undefined reference to `Polyglot_java_sql_Date_cdv'
/home/vagrant/JLang/app/src/DateTime.java:43: undefined reference to `Polyglot_java_sql_Date_Date(__complex)'
/tmp/DateTime-6d815f.o:(.data+0x68): undefined reference to `Polyglot_java_sql_Date_class_id'
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
Wrote compiled binary to AppExec.o
BTW, these application-specific errors are not my concern at all, I just want to build a multi-file application using JLang to see how it works.
I believe the issue you're still facing here is the same as in #66.
When you run the jlang
command, be sure to include the -cp jdk/out/classes
option (assuming you're in the top-level JLang directory.
I tried to build a random multi-file Java application using this manual on an Ubuntu 18.04 machine: $
pwd
$
tree
$
../bin/jlangc -cp ../jdk/out/classes -sourcepath ./src/ -d ./out -entry-point Start src/Start.java
$tree
$
find out -name "*.ll" | xargs ../bin/compile_ll.sh AppExec
or just compiling the Start.ll (since it's the entry point of the application): $
../bin/compile_ll.sh AppExec out/Start.ll
BTW, I had built the HelloWorld app successfully.
$
./bin/jlangc HelloWorld.java
$./bin/compile_ll.sh HelloWorld.ll
$
JAVA_HOME=$JDK7 ./HelloWorld.o