From 202aadd5cb51d9eafd839d3197ca577fea3bb804 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 24 Jul 2014 01:55:50 -0700 Subject: [PATCH] Add info for clang without -integrated-as support The -fblocks option can still be used with versions of clang that do not have integrated assembler support. The source file must first be compiled to a .s file using -fblocks and then that file compiled without -fblocks to the desired end product. Add support for this (and a warning message) to checktests and the README.txt file. --- .gitattributes | 4 ++++ .gitignore | 3 +++ README.txt | 41 +++++++++++++++++++++++++++++++++ checktests | 71 +++++++++++++++++++++++++++++++++++++++++++++------------- 4 files changed, 104 insertions(+), 15 deletions(-) diff --git a/.gitattributes b/.gitattributes index 328e03533..b37d0f310 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,7 @@ /README.md export-ignore .gitignore export-ignore .gitattributes export-ignore +/buildlib text eol=lf +/buildlib-osx text eol=lf +/checktests text eol=lf +/installlib text eol=lf diff --git a/.gitignore b/.gitignore index c86a0461b..b34dca98c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ *.o +*.s *.dSYM +*.exe +*.html /libBlocksRuntime.a /testbin /sample diff --git a/README.txt b/README.txt index c9b538619..ff9254a0f 100644 --- a/README.txt +++ b/README.txt @@ -154,6 +154,41 @@ the ARM hard float ABI is in use. +clang -fblocks failure +---------------------- + +If clang is not using the integrated assembler (option `-integrated-as`) then it +will incorrectly pass options such as `-fblocks` down to the assembler which +will probably not like it. One example of an error caused by this bug is: + + gcc: error: unrecognized command line option '-fblocks' + +In this case clang is not using the integrated assembler (which is not supported +on all platforms) and passes the `-fblocks` option down to the gcc assembler +which does not like that option at all. + +The following references talk about this: + +- +- + +The ugly workaround for this problem is to compile the sources using both the +`-S` and `-fblocks` options to produce a `.s` file which can then be compiled +into whatever is desired without needing to use the `-fblocks` option. + +If `checktests` detects this situation it will emit a line similar to this: + + WARNING: -S required for -fblocks with clang + +If this is the case, then rules to compile `.c` into `.s` and then compile `.s` +into `.o` (or whatever) will be needed instead of the usual compile `.c` into +`.o` (or whatever). + +Note that this workaround is required to use `-fblocks` with the version of +clang included with cygwin. + + + Installing ---------- @@ -194,6 +229,12 @@ just do this (replace `clang` with the name of the compiler you're using): If the above line outputs `Hello world 2` then your Blocks runtime support is correctly installed and fully usable. Have fun! +Note that if you have the problem described above in the section named +"clang -fblocks failure", then you'll need to do this instead: + + clang -S -o sample.s -fblocks sample.c && \ + clang -o sample sample.s -lBlocksRuntime && ./sample + Note that it's possible to use the Blocks runtime without installing it into the system directories. You simply need to add an appropriate `-I` option to find the `Block.h` header when you compile your source(s). And a `-L` option to diff --git a/checktests b/checktests index 8e8199ddb..a8617d35c 100755 --- a/checktests +++ b/checktests @@ -32,6 +32,7 @@ diagfilt() { echo '# '"$LINE" done } +usedashs= diag 'blocksruntime tests' '' if ! ccver="$("$CC" --version 2>&1)"; then echo 'Bail out! '"\"$CC\" not installed (did you forget to set \$CC?)" @@ -39,24 +40,47 @@ if ! ccver="$("$CC" --version 2>&1)"; then else out="$( ("$CC" -fblocks -c -o /dev/null -x c - < /dev/null 2>&1 || echo '-fblocks') 2>&1)" case "$out" in *"-fblocks"*) - echo 'Bail out! '"\"$CC\" does not support the -fblocks option" - exit 1 + out="$( ("$CC" -fblocks -S -o /dev/null -x c - < /dev/null 2>&1 || echo '-fblocks') 2>&1)" + case "$out" in *"-fblocks"*) + echo 'Bail out! '"\"$CC\" does not support the -fblocks option" + exit 1 + esac + usedashs=1 + diag "WARNING: -S required for -fblocks with $CC" esac ccmach="$("$CC" -dumpmachine 2>/dev/null)" fi +warnskipcxx= if cxxver="$("$CXX" --version 2>&1)"; then dopp=1 out="$( ("$CXX" -fblocks -c -o /dev/null -x c - < /dev/null 2>&1 || echo '-fblocks') 2>&1)" case "$out" in *"-fblocks"*) - diag "\"$CXX\" does not support the -fblocks option; skipping C++ tests" "" - dopp= + out="$( ("$CXX" -fblocks -S -o /dev/null -x c - < /dev/null 2>&1 || echo '-fblocks') 2>&1)" + case "$out" in + *"-fblocks"*) + warnskipcxx="\"$CXX\" does not support the -fblocks option; skipping C++ tests" + dopp= + ;; + *) + usedashs=1 + ;; + esac + if [ "$CC" != "$CXX" ]; then + diag "WARNING: -S required for -fblocks with $CXX" + fi esac if [ -n "$dopp" ]; then cxxmach="$("$CXX" -dumpmachine 2>/dev/null)" cxxdver="$("$CXX" -dumpversion 2>/dev/null)" fi else - diag "\"$CXX\" not installed; skipping C++ tests" "" + warnskipcxx="\"$CXX\" not installed; skipping C++ tests" +fi +if [ -n "$usedashs" ]; then + diag "" +fi +if [ -n "$warnskipcxx" ]; then + diag "$warnskipcxx" "" fi if [ ! -r "$LIB" ]; then echo 'Bail out! '"No \"$LIB\" file found, try running \"$(dirname "$0")/buildlib\" first" @@ -174,17 +198,34 @@ for test in BlocksRuntime/tests/*.[cC]; do skipcount=$(($skipcount + 1)) else if [ -n "$stub" ]; then - out="$( ( \ - "$USECC" -c $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).o -fblocks $test && \ - echo "$stub" | "$USECC" $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext) -fblocks \ - $TESTDIR/$(basename $test $ext).o $USELIB -x c - && \ - cd $TESTDIR && PATH=. $(basename $test $ext) \ + out="$( ( + if [ -z "$usedashs" ]; then + "$USECC" -c $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).o -fblocks $test && \ + echo "$stub" | "$USECC" $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext) -fblocks \ + $TESTDIR/$(basename $test $ext).o $USELIB -x c - && \ + cd $TESTDIR && ./$(basename $test $ext) + else + "$USECC" -S $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).s -fblocks $test && \ + "$USECC" -c $CFLAGS $extra -o $TESTDIR/$(basename $test $ext).o \ + $TESTDIR/$(basename $test $ext).s && \ + echo "$stub" | "$USECC" $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext) \ + $TESTDIR/$(basename $test $ext).o $USELIB -x c - && \ + cd $TESTDIR && ./$(basename $test $ext) + fi ) 2>&1)" else - out="$( ( \ - "$USECC" -c $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).o -fblocks $test && \ - "$USECC" $CFLAGS -o $TESTDIR/$(basename $test $ext) -fblocks $TESTDIR/$(basename $test $ext).o $USELIB && \ - cd $TESTDIR && PATH=. $(basename $test $ext) \ + out="$( ( + if [ -z "$usedashs" ]; then + "$USECC" -c $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).o -fblocks $test && \ + "$USECC" $CFLAGS -o $TESTDIR/$(basename $test $ext) -fblocks $TESTDIR/$(basename $test $ext).o $USELIB && \ + cd $TESTDIR && ./$(basename $test $ext) + else + "$USECC" -S $CFLAGS $USEFLAGS $extra -o $TESTDIR/$(basename $test $ext).s -fblocks $test && \ + "$USECC" -c $CFLAGS $extra -o $TESTDIR/$(basename $test $ext).o \ + $TESTDIR/$(basename $test $ext).s && \ + "$USECC" $CFLAGS -o $TESTDIR/$(basename $test $ext) $TESTDIR/$(basename $test $ext).o $USELIB && \ + cd $TESTDIR && ./$(basename $test $ext) + fi ) 2>&1)" fi result=$? @@ -204,7 +245,7 @@ for test in BlocksRuntime/tests/*.[cC]; do else if [ $result != 0 ]; then testsfailed=1 - failcount=$(($failcount + 1)) + failcount=$(($failcount + 1)) echo "not ok $testcount - $testname" echo "$out" | diagfilt else -- 2.11.4.GIT