Constellation / iv

ECMAScript Lexer / Parser / Interpreter / VM / method JIT written in C++
BSD 2-Clause "Simplified" License
415 stars 32 forks source link

SPARC build failed #99

Open syoyo opened 9 years ago

syoyo commented 9 years ago

SPARC build of iv/lv5 fails with libgc related issue.

http://qiita.com/syoyo/items/0068f514f606a6b1a91e

It looks like some file(s) are missing in CMakeList.txt when targeting SPARC architecture.

At least, with the following patch, I could get success to build libgc.

$ make
…

Building C object iv/lv5/third_party/gc/CMakeFiles/gcmt-lib.dir/thread_local_alloc.c.o
Building ASM object iv/lv5/third_party/gc/CMakeFiles/gcmt-lib.dir/src/sparc_mach_dep.S.o
Linking CXX executable gctest
Linking CXX shared library libgcmt-dll.so
Linking CXX static library libgcmt-lib.a
[100%] Built target gctest
[100%] Built target gcmt-dll
[100%] Built target gcmt-lib

$ cd test
$ ./gctest 
Completed 1 tests
Allocated 748193 collectable objects
Allocated 202 uncollectable objects
Allocated 1250000 atomic objects
Allocated 21760 stubborn objects
Finalized 2206/2206 objects - finalization is probably ok
Total number of bytes allocated is 103987300
Final heap size is 10211328 bytes
Completed 78 collections
Collector appears to work
diff --git a/iv/lv5/third_party/gc/CMakeLists.txt b/iv/lv5/third_party/gc/CMakeLists.txt
index e538f23..4cf1b9c 100644
--- a/iv/lv5/third_party/gc/CMakeLists.txt
+++ b/iv/lv5/third_party/gc/CMakeLists.txt
@@ -22,6 +22,7 @@
 #

 SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
+enable_language(ASM)

 PROJECT(gc)

@@ -62,7 +63,7 @@ SET(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c
         mark_rts.c headers.c mark.c obj_map.c blacklst.c finalize.c
         new_hblk.c dbg_mlc.c malloc.c stubborn.c dyn_load.c
         typd_mlc.c ptr_chck.c gc_cpp.cc mallocx.c checksums.c
-        thread_local_alloc.c)
+        thread_local_alloc.c src/sparc_mach_dep.S)
 SET(LIBS)
 OPTION(enable_threads "TODO" NO)
 IF(enable_threads)
Constellation commented 9 years ago

Cool! I've added the support code to CMakeLists.txt. Coud you try it? Since this CMakeLists.txt is basically derived from the original source of BoehmGC, once this issue is fixed, we can contribute BoehmGC repository to fix CMake build on SPARC :)

syoyo commented 9 years ago

This works on our SPARC, finally!

diff --git a/iv/lv5/third_party/gc/CMakeLists.txt b/iv/lv5/third_party/gc/CMakeLists.txt
index 5e4b22f..9125c86 100644
--- a/iv/lv5/third_party/gc/CMakeLists.txt
+++ b/iv/lv5/third_party/gc/CMakeLists.txt
@@ -66,7 +66,7 @@ SET(SRC alloc.c reclaim.c allchblk.c misc.c mach_dep.c os_dep.c

 #FIXME(Yusuke Suzuki): added
 SET(ASM_NEEDED false)
-IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
+IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc|s64fx")
   IF(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
     SET(SRC ${SRC} src/sparc_netbsd_mach_dep.s)
   ELSE()
Constellation commented 9 years ago

@syoyo:

Great! I'll merge your change :)