Merge: Removed sockets from 'debugger.nit' to put them in a new module
authorJean Privat <jean@pryen.org>
Wed, 25 Jun 2014 19:56:36 +0000 (15:56 -0400)
committerJean Privat <jean@pryen.org>
Wed, 25 Jun 2014 19:56:36 +0000 (15:56 -0400)
Removed sockets from 'debugger.nit' to put them in 'debugger_socket.nit', because it caused compilation problems for the interpreter in PNaCl.

Pull-Request: #520
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

20 files changed:
.mailmap
benchmarks/bench_common.sh [new file with mode: 0644]
benchmarks/bench_engines.sh
benchmarks/bench_languages.sh
c_src/Makefile
src/Makefile
src/abstract_compiler.nit
src/global_compiler.nit
src/mkcsrc
tests/emscripten.skip [new file with mode: 0644]
tests/emscripten_nodejs.nit [new file with mode: 0644]
tests/sav/emscripten/emscripten_nodejs.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_attr_gen_alt1.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_conflict_submodule_name.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_conflict_submodule_name_alt1.res [new file with mode: 0644]
tests/sav/emscripten/fixme/base_conflict_submodule_name_alt2.res [new file with mode: 0644]
tests/sav/emscripten_nodejs.res [new file with mode: 0644]
tests/sav/nitg-s/fixme/base_attr_gen_alt1.res
tests/sav/nitg-sg/fixme/base_attr_gen_alt1.res
tests/tests.sh

index a3e389c..695a4ce 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -23,3 +23,5 @@ Romain Chanoir <romain.chanoir@viacesi.fr>
 Clement de Figueiredo <clement.defigueiredo@gmail.com>
 
 Christophe Gigax <christophe.gigax@viacesi.fr>
+
+Julien Pagès <julien.projet@gmail.com>
diff --git a/benchmarks/bench_common.sh b/benchmarks/bench_common.sh
new file mode 100644 (file)
index 0000000..c600732
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/bash
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Common functions for all the bench scripts
+
+# Run a single command multiple time and store the execution times
+# in the current $res file.
+#
+#  $1: title of the command
+#  $2: long desription of the command
+#  rest: the command to execute
+function bench_command()
+{
+       if [ "$dry_run" = "true" ]; then return; fi
+       local title="$1"
+       local desc="$2"
+       shift
+       shift
+       if test "$verbose" = true; then outputopts="/dev/stdout"; else outputopts="/dev/null"; fi
+       timeout="time.out"
+       echo "$title" > "$timeout"
+       echo "# $desc" >> "$timeout"
+       echo "\$ $@" >> "$timeout"
+       echo
+       echo "** [$title] $desc **"
+       echo " $ $@"
+
+       # Execute the commands $count times
+       for i in `seq 1 "$count"`; do
+               /usr/bin/time -f "%U" -o "$timeout" -a "$@" > $outputopts 2>&1 || die "$1: failed"
+               echo -n "$i. "
+               tail -n 1 "$timeout"
+       done
+
+       line=`compute_stats "$timeout"`
+       echo "$line ($res)"
+       echo $line >> "$res"
+}
+
+# Run a simble command witout storing the execution time
+# Used to display command on verbose and skip long executions when dry_run is given
+# $@ command to execute
+function run_command()
+{
+       if [ "$dry_run" = "true" ]; then return; fi
+       echo " $ $@"
+       "$@" || die "$@: failed"
+}
+
+# Check if the test should be skiped according to its name
+# $1: name of the test
+# $2: description of the test
+# $NOTSKIPED: arguments
+function skip_test()
+{
+       if test -z "$NOTSKIPED"; then
+               echo "* $1"
+               return 0
+       fi
+       if test "$NOTSKIPED" = "all"; then
+               : # Execute anyway
+       elif echo "$1" | egrep "$NOTSKIPED" >/dev/null 2>&1; then
+               : # Found one to execute
+       else
+               return 0
+       fi
+       if test -n "$html"; then
+               echo >>"$html" "<h2>$1</h2>"
+       fi
+       echo "*"
+       echo "* $1 *****"
+       echo "*"
+       return 1
+}
+
index 55db63e..abc65e3 100755 (executable)
@@ -17,6 +17,7 @@
 
 # TODO: cleanup and libify the helper-parts
 
+source ./bench_common.sh
 source ./bench_plot.sh
 
 ## CONFIGURATION OPTIONS ##
@@ -35,76 +36,6 @@ function die()
        died=1
 }
 
-# Run a single command multiple time and store the execution times
-# in the current $res file.
-#
-#  $1: title of the command
-#  $2: long desription of the command
-#  rest: the command to execute
-function bench_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       local title="$1"
-       local desc="$2"
-       shift
-       shift
-       if test "$verbose" = true; then outputopts="/dev/stdout"; else outputopts="/dev/null"; fi
-       timeout="time.out"
-       echo "$title" > "$timeout"
-       echo "# $desc" >> "$timeout"
-       echo "\$ $@" >> "$timeout"
-       echo
-       echo "** [$title] $desc **"
-       echo " $ $@"
-
-       # Execute the commands $count times
-       for i in `seq 1 "$count"`; do
-               /usr/bin/time -f "%U" -o "$timeout" -a "$@" > $outputopts 2>&1 || die "$1: failed"
-               echo -n "$i. "
-               tail -n 1 "$timeout"
-       done
-
-       line=`compute_stats "$timeout"`
-       echo "$line ($res)"
-       echo $line >> "$res"
-}
-
-# Run a simble command witout storing the execution time
-# Used to display command on verbose and skip long executions when dry_run is given
-# $@ command to execute
-function run_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       echo " $ $@"
-       "$@" || die "$@: failed"
-}
-
-# Check if the test should be skiped according to its name
-# $1: name of the test
-# $2: description of the test
-# $NOTSKIPED: arguments
-function skip_test()
-{
-       if test -z "$NOTSKIPED"; then
-               echo "* $1"
-               return 0
-       fi
-       if test "$NOTSKIPED" = "all"; then
-               : # Execute anyway
-       elif echo "$1" | egrep "$NOTSKIPED" >/dev/null 2>&1; then
-               : # Found one to execute
-       else
-               return 0
-       fi
-       if test -n "$html"; then
-               echo >>"$html" "<h2>$1</h2>"
-       fi
-       echo "*"
-       echo "* $1 *****"
-       echo "*"
-       return 1
-}
-
 # HELPER FOR NIT #
 
 # Run standards benchs on a compiler command
index d9db525..fea39ff 100755 (executable)
@@ -17,6 +17,7 @@
 
 # TODO: cleanup and libify the helper-parts
 
+source ./bench_common.sh
 source ./bench_plot.sh
 
 ## CONFIGURATION OPTIONS ##
@@ -33,74 +34,6 @@ function die()
        died=1
 }
 
-# Run a single command multiple time and store the execution times
-# in the current $res file.
-#
-#  $1: title of the command
-#  $2: long desription of the command
-#  rest: the command to execute
-function bench_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       local title="$1"
-       local desc="$2"
-       shift
-       shift
-       if test "$verbose" = true; then outputopts="/dev/stdout"; else outputopts="/dev/null"; fi
-       timeout="time.out"
-       echo "$title" > "$timeout"
-       echo "# $desc" >> "$timeout"
-       echo "\$ $@" >> "$timeout"
-       echo
-       echo "** [$title] $desc **"
-       echo " $ $@"
-
-       # Execute the commands $count times
-       for i in `seq 1 "$count"`; do
-               (ulimit -t 300; /usr/bin/time -f "%U" -o "$timeout" -a "$@") > $outputopts 2>&1 || die "$1: failed"
-               echo -n "$i. "
-               tail -n 1 "$timeout"
-       done
-
-       line=`compute_stats "$timeout"`
-       echo "$line ($res)"
-       echo $line >> "$res"
-       rm $timeout
-}
-
-# Run a simple command witout storing the execution time
-# Used to display command on verbose and skip long executions when dry_run is given
-# $@ command to execute
-function run_command()
-{
-       if [ "$dry_run" = "true" ]; then return; fi
-       echo " $ $@"
-       (ulimit -t 180; "$@") || die "$@: failed"
-}
-
-# Check if the test should be skiped according to its name
-# $1: name of the test
-# $2: description of the test
-# $NOTSKIPED: arguments
-function skip_test()
-{
-       if test -z "$NOTSKIPED"; then
-               echo "* $1"
-               return 0
-       fi
-       if test "$NOTSKIPED" = "all"; then
-               : # Execute anyway
-       elif echo "$1" | egrep "$NOTSKIPED" >/dev/null 2>&1; then
-               : # Found one to execute
-       else
-               return 0
-       fi
-       echo "*"
-       echo "* $1 *****"
-       echo "*"
-       return 1
-}
-
 ## HANDLE OPTIONS ##
 
 function usage()
index 1453943..d94866c 100644 (file)
@@ -1,8 +1,22 @@
 CC = ccache cc
-CFLAGS = -g -O2
+CFLAGS = -g -O2 -Wno-unused-value -Wno-switch
 CINCL =  -I "clib"
 LDFLAGS ?= 
-LDLIBS  ?= -lm -lgc  -lunwind
+LDLIBS  ?= -lm -lgc
+
+NEED_LIBUNWIND := YesPlease
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+ifeq ($(uname_S),Darwin)
+       NEED_LIBUNWIND :=
+endif
+
+clang_check := $(shell sh -c '$(CC) -v 2>&1 | grep -q clang; echo $$?')
+ifeq ($(clang_check), 0)
+       CFLAGS += -Qunused-arguments
+endif
+ifdef NEED_LIBUNWIND
+       LDLIBS += -lunwind
+endif
 
 all: nitg
 
index 211287d..2ca0fb7 100644 (file)
@@ -15,6 +15,7 @@
 # limitations under the License.
 
 NITCOPT=
+OLDNITCOPT= --no-stacktrace
 
 all: ../bin/nitdoc ../bin/nitmetrics ../bin/nitg ../bin/nit ../bin/nitx ../bin/nitunit ../bin/nitlight ../bin/nitls ../bin/nitdbg_client
 
@@ -23,7 +24,7 @@ nitg_0: ../c_src/nitg parser/parser.nit
        @echo '* Compile nitg_0 from NIT source files                          *'
        @echo '***************************************************************'
        ./git-gen-version.sh
-       ../c_src/nitg ${NITCOPT} -o nitg_0 -v nitg.nit
+       ../c_src/nitg ${OLDNITCOPT} -o nitg_0 -v nitg.nit
 
 ../bin/nitg: nitg_0 parser/parser.nit
        @echo '***************************************************************'
index 99b84be..e8d0179 100644 (file)
@@ -320,10 +320,28 @@ class MakefileToolchain
                        if libs != null then linker_options.add_all(libs)
                end
 
+               makefile.write("CC = ccache cc\nCFLAGS = -g -O2 -Wno-unused-value -Wno-switch\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS  ?= -lm -lgc {linker_options.join(" ")}\n\n")
+
                var ost = toolcontext.opt_stacktrace.value
-               if ost == "libunwind" or ost == "nitstack" then linker_options.add("-lunwind")
+               if ost == "libunwind" or ost == "nitstack" then makefile.write("NEED_LIBUNWIND := YesPlease\n")
+
+               # Dynamic adaptations
+               # While `platform` enable complex toolchains, they are statically applied
+               # For a dynamic adaptsation of the compilation, the generated Makefile should check and adapt things itself
+
+               # Check and adapt the targeted system
+               makefile.write("uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n")
+               makefile.write("ifeq ($(uname_S),Darwin)\n")
+               # remove -lunwind since it is already included on macosx
+               makefile.write("\tNEED_LIBUNWIND :=\n")
+               makefile.write("endif\n\n")
+
+               # Check and adapt for the compiler used
+               # clang need an additionnal `-Qunused-arguments`
+               makefile.write("clang_check := $(shell sh -c '$(CC) -v 2>&1 | grep -q clang; echo $$?')\nifeq ($(clang_check), 0)\n\tCFLAGS += -Qunused-arguments\nendif\n")
+
+               makefile.write("ifdef NEED_LIBUNWIND\n\tLDLIBS += -lunwind\nendif\n")
 
-               makefile.write("CC = ccache cc\nCFLAGS = -g -O2\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS  ?= -lm -lgc {linker_options.join(" ")}\n\n")
                makefile.write("all: {outpath}\n\n")
 
                var ofiles = new Array[String]
index 8c6ac6c..9e79281 100644 (file)
@@ -124,8 +124,8 @@ class GlobalCompiler
        # Compile class names (for the class_name and output_class_name methods)
        protected fun compile_class_names do
                var v = new_visitor
-               self.header.add_decl("extern const char const * class_names[];")
-               v.add("const char const * class_names[] = \{")
+               self.header.add_decl("extern const char *class_names[];")
+               v.add("const char *class_names[] = \{")
                for t in self.runtime_type_analysis.live_types do
                        v.add("\"{t}\", /* {self.classid(t)} */")
                end
index a408697..7ba4466 100755 (executable)
@@ -21,3 +21,6 @@ done
 perl -i -npe 's#"\.\./.*?([^/]*.h)"#"\1"#' "$out"/*.[ch]
 perl -i -npe 's#\S*/([^/]*.[ch])#\1#' "$out/Makefile"
 perl -i -npe 's#\.\./clib#.#' "$out/Makefile"
+
+# Remove old compilation flags
+sed -i -e 's/OLDNITCOPT=.*/OLDNITCOPT=/' src/Makefile
diff --git a/tests/emscripten.skip b/tests/emscripten.skip
new file mode 100644 (file)
index 0000000..c782ec0
--- /dev/null
@@ -0,0 +1,2 @@
+init_inherit
+init_linext
diff --git a/tests/emscripten_nodejs.nit b/tests/emscripten_nodejs.nit
new file mode 100644 (file)
index 0000000..5ada70d
--- /dev/null
@@ -0,0 +1,13 @@
+import emscripten
+redef class IFStream
+       redef fun fill_buffer
+       do
+               print "NOT YET IMPLEMENTED"
+               abort
+       end
+       redef init open(f)
+       do
+               print "NOT YET IMPLEMENTED"
+               abort
+       end
+end
diff --git a/tests/sav/emscripten/emscripten_nodejs.res b/tests/sav/emscripten/emscripten_nodejs.res
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/sav/emscripten/fixme/base_attr_gen_alt1.res b/tests/sav/emscripten/fixme/base_attr_gen_alt1.res
new file mode 100644 (file)
index 0000000..b4de394
--- /dev/null
@@ -0,0 +1 @@
+11
diff --git a/tests/sav/emscripten/fixme/base_conflict_submodule_name.res b/tests/sav/emscripten/fixme/base_conflict_submodule_name.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt1.res b/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt1.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt2.res b/tests/sav/emscripten/fixme/base_conflict_submodule_name_alt2.res
new file mode 100644 (file)
index 0000000..4ad3dc3
--- /dev/null
@@ -0,0 +1 @@
+UNDEFINED
diff --git a/tests/sav/emscripten_nodejs.res b/tests/sav/emscripten_nodejs.res
new file mode 100644 (file)
index 0000000..174d681
--- /dev/null
@@ -0,0 +1 @@
+Not executable (platform?)
index b8ecd0a..6cfb9be 100755 (executable)
@@ -19,6 +19,7 @@
 
 # Set lang do default to avoid failed tests because of locale
 export LANG=C
+export LC_ALL=C
 export NIT_TESTING=true
 
 unset NIT_DIR
@@ -318,6 +319,11 @@ case $engine in
        niti)
                enginebinname=nit
                ;;
+       emscripten)
+               enginebinname=nitg
+               OPT="-m emscripten_nodejs.nit --semi-global $OPT"
+               savdirs="sav/nitg-sg/"
+               ;;
        nitc)
                echo "disabled engine $engine"
                exit 0
@@ -409,6 +415,11 @@ for ii in "$@"; do
                        inputs=/dev/null
                fi
 
+               ffout="$ff.bin"
+               if [ "$engine" = "emscripten" ]; then
+                       ffout="$ff.bin.js"
+               fi
+
                if [ "$engine" = "niti" ]; then
                        cat > "./$ff.bin" <<END
 exec $NITC --no-color $OPT "$i" $includes -- "\$@"
@@ -426,16 +437,25 @@ END
                        # Compile
                        if [ "x$verbose" = "xtrue" ]; then
                                echo ""
-                               echo $NITC --no-color $OPT -o "$ff.bin" "$i" "$includes" $nocc
+                               echo $NITC --no-color $OPT -o "$ffout" "$i" "$includes" $nocc
                        fi
                        NIT_NO_STACK=1 JNI_LIB_PATH=$JNI_LIB_PATH JAVA_HOME=$JAVA_HOME \
-                               $TIMEOUT $NITC --no-color $OPT -o "$ff.bin" "$i" $includes $nocc 2> "$ff.cmp.err" > "$ff.compile.log"
+                               $TIMEOUT $NITC --no-color $OPT -o "$ffout" "$i" $includes $nocc 2> "$ff.cmp.err" > "$ff.compile.log"
                        ERR=$?
                        if [ "x$verbose" = "xtrue" ]; then
                                cat "$ff.compile.log"
                                cat >&2 "$ff.cmp.err"
                        fi
                fi
+               if [ "$engine" = "emscripten" ]; then
+                       echo > "./$ff.bin" "nodejs $ffout \"\$@\""
+                       chmod +x "$ff.bin"
+                       if grep "Fatal Error: more than one primitive class" "$ff.compile.log" > /dev/null; then
+                               echo " [skip] do no not imports kernel"
+                               echo >>$xml "<testcase classname='$pack' name='$bf'><skipped/></testcase>"
+                               continue
+                       fi
+               fi
                if [ "$ERR" != 0 ]; then
                        echo -n "! "
                        cat "$ff.compile.log" "$ff.cmp.err" > "$ff.res"