Skip to content
Permalink
Browse files

core, feat: migrate compilation to clang on linux.

  • Loading branch information...
xicilion committed Apr 4, 2019
1 parent 84a8981 commit 5c3c59c447c38b08348f4f5aebaae743119bc082
Showing with 39 additions and 42 deletions.
  1. +3 −2 BUILDING.md
  2. +9 −4 build
  3. +14 −21 fibjs/build
  4. +11 −11 fibjs/program/build
  5. +1 −3 test/util_test.js
  6. +1 −1 vender
@@ -2,7 +2,7 @@

## Prerequisites (unix)

- GCC 4.8 or newer
- CLang 3.8 or newer
- CMake 2.6 or newer
- GNU Make 3.81 or newer
- libexecinfo (FreeBSD and OpenBSD only)
@@ -11,10 +11,11 @@
### on ubuntu:

```sh
apt install g++
apt install clang
apt install make
apt install cmake
apt install git
apt install ccache
```

### 32bit on ubuntu:
13 build
@@ -61,11 +61,11 @@ do
;;
-j*) ENABLE_JOBS=1; BUILD_JOBS="${i#-j}"
;;
-v) BUILD_VERBOSE='VERBOSE=1'
-v) BUILD_VERBOSE='VERBOSE=1'
;;
--help|-h) usage
--help|-h) usage
;;
*) echo "illegal option $i"
*) echo "illegal option $i"
usage
;;
esac
@@ -90,42 +90,47 @@ if [ $TARGET_ARCH != $HOST_ARCH ] || [ $TARGET_OS != $HOST_OS ]; then
arm)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="arm-linux-gnueabihf-"
BUILD_OPTION="-march=armv7-a -mfpu=vfp3 -marm"
BUILD_OPTION="-march=armv7-a -mfpu=vfp3 -marm --target=arm-linux-gnueabihf -L/usr/lib/gcc-cross/arm-linux-gnueabihf/5 -L/usr/arm-linux-gnueabihf/lib -I/usr/arm-linux-gnueabihf/include -I/usr/arm-linux-gnueabihf/include/c++/5 -I/usr/arm-linux-gnueabihf/include/c++/5/arm-linux-gnueabihf"
else
usage
fi
;;
arm64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="aarch64-linux-gnu-"
BUILD_OPTION="--target=aarch64-linux-gnu -L/usr/lib/gcc-cross/aarch64-linux-gnu/5 -L/usr/aarch64-linux-gnu/lib -I/usr/aarch64-linux-gnu/include -I/usr/aarch64-linux-gnu/include/c++/5 -I/usr/aarch64-linux-gnu/include/c++/5/aarch64-linux-gnu"
else
usage
fi
;;
mips)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="mips-linux-gnu-"
BUILD_OPTION="--target=mips-linux-gnu -L/usr/lib/gcc-cross/mips-linux-gnu/5 -L/usr/mips-linux-gnu/lib -I/usr/mips-linux-gnu/include -I/usr/mips-linux-gnu/include/c++/5 -I/usr/mips-linux-gnu/include/c++/5/mips-linux-gnu"
else
usage
fi
;;
mips64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="mips64-linux-gnuabi64-"
BUILD_OPTION="--target=mips64-linux-gnuabi64 -L/usr/lib/gcc-cross/mips64-linux-gnuabi64/5 -L/usr/mips64-linux-gnuabi64/lib -I/usr/mips64-linux-gnuabi64/include -I/usr/mips64-linux-gnuabi64/include/c++/5 -I/usr/mips64-linux-gnuabi64/include/c++/5/mips64-linux-gnuabi64"
else
usage
fi
;;
ppc)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="powerpc-linux-gnu-"
BUILD_OPTION="--target=powerpc-linux-gnu -L/usr/lib/gcc-cross/powerpc-linux-gnu/5 -L/usr/powerpc-linux-gnu/lib -I/usr/powerpc-linux-gnu/include -I/usr/powerpc-linux-gnu/include/c++/5 -I/usr/powerpc-linux-gnu/include/c++/5/powerpc-linux-gnu"
else
usage
fi
;;
ppc64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="powerpc64-linux-gnu-"
BUILD_OPTION="--target=powerpc64-linux-gnu -L/usr/lib/gcc-cross/powerpc64-linux-gnu/5 -L/usr/powerpc64-linux-gnu/lib -I/usr/powerpc64-linux-gnu/include -I/usr/powerpc64-linux-gnu/include/c++/5 -I/usr/powerpc64-linux-gnu/include/c++/5/powerpc64-linux-gnu"
else
usage
fi
@@ -44,7 +44,6 @@ esac
TARGET_OS=$HOST_OS
TARGET_ARCH=$HOST_ARCH
BUILD_TYPE="release"
BUILD_PREFIX=""
BUILD_OPTION=""

for i in "$@"
@@ -54,11 +53,11 @@ do
;;
release|debug|clean) BUILD_TYPE=$i
;;
ci) CI="ci"
ci) CI="ci"
;;
--help|-h) usage
--help|-h) usage
;;
*) echo "illegal option $i"
*) echo "illegal option $i"
usage
;;
esac
@@ -74,63 +73,55 @@ if [ $TARGET_ARCH != $HOST_ARCH ] || [ $TARGET_OS != $HOST_OS ]; then
fi
;;
amd64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="x86_64-linux-gnu-"
else
if [ $TARGET_OS != "Linux" ]; then
usage
fi
;;
arm)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="arm-linux-gnueabihf-"
BUILD_OPTION="-march=armv7-a -mfpu=vfp3 -marm"
BUILD_OPTION="-march=armv7-a -mfpu=vfp3 -marm --target=arm-linux-gnueabihf -L/usr/lib/gcc-cross/arm-linux-gnueabihf/5 -L/usr/arm-linux-gnueabihf/lib -I/usr/arm-linux-gnueabihf/include -I/usr/arm-linux-gnueabihf/include/c++/5 -I/usr/arm-linux-gnueabihf/include/c++/5/arm-linux-gnueabihf"
else
usage
fi
;;
arm64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="aarch64-linux-gnu-"
BUILD_OPTION="--target=aarch64-linux-gnu -L/usr/lib/gcc-cross/aarch64-linux-gnu/5 -L/usr/aarch64-linux-gnu/lib -I/usr/aarch64-linux-gnu/include -I/usr/aarch64-linux-gnu/include/c++/5 -I/usr/aarch64-linux-gnu/include/c++/5/aarch64-linux-gnu"
else
usage
fi
;;
mips)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="mips-linux-gnu-"
BUILD_OPTION="--target=mips-linux-gnu -L/usr/lib/gcc-cross/mips-linux-gnu/5 -L/usr/mips-linux-gnu/lib -I/usr/mips-linux-gnu/include -I/usr/mips-linux-gnu/include/c++/5 -I/usr/mips-linux-gnu/include/c++/5/mips-linux-gnu"
else
usage
fi
;;
mips64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="mips64-linux-gnuabi64-"
BUILD_OPTION="--target=mips64-linux-gnuabi64 -L/usr/lib/gcc-cross/mips64-linux-gnuabi64/5 -L/usr/mips64-linux-gnuabi64/lib -I/usr/mips64-linux-gnuabi64/include -I/usr/mips64-linux-gnuabi64/include/c++/5 -I/usr/mips64-linux-gnuabi64/include/c++/5/mips64-linux-gnuabi64"
else
usage
fi
;;
ppc)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="powerpc-linux-gnu-"
BUILD_OPTION="--target=powerpc-linux-gnu -L/usr/lib/gcc-cross/powerpc-linux-gnu/5 -L/usr/powerpc-linux-gnu/lib -I/usr/powerpc-linux-gnu/include -I/usr/powerpc-linux-gnu/include/c++/5 -I/usr/powerpc-linux-gnu/include/c++/5/powerpc-linux-gnu"
else
usage
fi
;;
ppc64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="powerpc64-linux-gnu-"
BUILD_OPTION="--target=powerpc64-linux-gnu -L/usr/lib/gcc-cross/powerpc64-linux-gnu/5 -L/usr/powerpc64-linux-gnu/lib -I/usr/powerpc64-linux-gnu/include -I/usr/powerpc64-linux-gnu/include/c++/5 -I/usr/powerpc64-linux-gnu/include/c++/5/powerpc64-linux-gnu"
else
usage
fi
;;
esac
fi

if [ "$BUILD_PREFIX" != "" ]; then
export CC=${BUILD_PREFIX}gcc
export CXX=${BUILD_PREFIX}g++
fi

FIBJS_PATH=`pwd`
OUT_PATH=${FIBJS_PATH}/../out
BIN_ROOT=${FIBJS_PATH}/../bin
@@ -154,6 +145,7 @@ fi

OUT_PATH=${OUT_PATH}/${TARGET_OS}_${TARGET_ARCH}_${BUILD_TYPE}
if [ ! -e ${OUT_PATH} ]; then
print " ${OUT_PATH}"
mkdir ${OUT_PATH}
fi

@@ -165,7 +157,8 @@ fi
GIT_INFO=`git describe`

cd ${OUT_PATH}
cmake -DBUILD_TYPE=${BUILD_TYPE} -DBUILD_OPTION="${BUILD_OPTION}" -DGIT_INFO=$GIT_INFO ${FIBJS_PATH} > CMake.log
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_TYPE=${BUILD_TYPE} -DBUILD_OPTION="${BUILD_OPTION}" -DGIT_INFO=$GIT_INFO ${FIBJS_PATH} > CMake.log

if [ $? != 0 ]; then
exit 1
fi
@@ -179,4 +172,4 @@ if [ $? != 0 ]; then
exit 1
fi

cd "${FIBJS_PATH}"
cd "${FIBJS_PATH}"
@@ -54,11 +54,11 @@ do
;;
release|debug|clean) BUILD_TYPE=$i
;;
ci) CI="ci"
ci) CI="ci"
;;
--help|-h) usage
--help|-h) usage
;;
*) echo "illegal option $i"
*) echo "illegal option $i"
usage
;;
esac
@@ -83,54 +83,54 @@ if [ $TARGET_ARCH != $HOST_ARCH ] || [ $TARGET_OS != $HOST_OS ]; then
arm)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="arm-linux-gnueabihf-"
BUILD_OPTION="-march=armv7-a -mfpu=vfp3 -marm"
BUILD_OPTION="-march=armv7-a -mfpu=vfp3 -marm --target=arm-linux-gnueabihf -L/usr/lib/gcc-cross/arm-linux-gnueabihf/5 -L/usr/arm-linux-gnueabihf/lib -I/usr/arm-linux-gnueabihf/include -I/usr/arm-linux-gnueabihf/include/c++/5 -I/usr/arm-linux-gnueabihf/include/c++/5/arm-linux-gnueabihf"
else
usage
fi
;;
arm64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="aarch64-linux-gnu-"
BUILD_OPTION="--target=aarch64-linux-gnu -L/usr/lib/gcc-cross/aarch64-linux-gnu/5 -L/usr/aarch64-linux-gnu/lib -I/usr/aarch64-linux-gnu/include -I/usr/aarch64-linux-gnu/include/c++/5 -I/usr/aarch64-linux-gnu/include/c++/5/aarch64-linux-gnu"
else
usage
fi
;;
mips)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="mips-linux-gnu-"
BUILD_OPTION="--target=mips-linux-gnu -L/usr/lib/gcc-cross/mips-linux-gnu/5 -L/usr/mips-linux-gnu/lib -I/usr/mips-linux-gnu/include -I/usr/mips-linux-gnu/include/c++/5 -I/usr/mips-linux-gnu/include/c++/5/mips-linux-gnu"
else
usage
fi
;;
mips64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="mips64-linux-gnuabi64-"
BUILD_OPTION="--target=mips64-linux-gnuabi64 -L/usr/lib/gcc-cross/mips64-linux-gnuabi64/5 -L/usr/mips64-linux-gnuabi64/lib -I/usr/mips64-linux-gnuabi64/include -I/usr/mips64-linux-gnuabi64/include/c++/5 -I/usr/mips64-linux-gnuabi64/include/c++/5/mips64-linux-gnuabi64"
else
usage
fi
;;
ppc)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="powerpc-linux-gnu-"
BUILD_OPTION="--target=powerpc-linux-gnu -L/usr/lib/gcc-cross/powerpc-linux-gnu/5 -L/usr/powerpc-linux-gnu/lib -I/usr/powerpc-linux-gnu/include -I/usr/powerpc-linux-gnu/include/c++/5 -I/usr/powerpc-linux-gnu/include/c++/5/powerpc-linux-gnu"
else
usage
fi
;;
ppc64)
if [ $TARGET_OS = "Linux" ]; then
BUILD_PREFIX="powerpc64-linux-gnu-"
BUILD_OPTION="--target=powerpc64-linux-gnu -L/usr/lib/gcc-cross/powerpc64-linux-gnu/5 -L/usr/powerpc64-linux-gnu/lib -I/usr/powerpc64-linux-gnu/include -I/usr/powerpc64-linux-gnu/include/c++/5 -I/usr/powerpc64-linux-gnu/include/c++/5/powerpc64-linux-gnu"
else
usage
fi
;;
esac
fi

if [ "$BUILD_PREFIX" != "" ]; then
export CC=${BUILD_PREFIX}gcc
export CXX=${BUILD_PREFIX}g++
fi

FIBJS_PATH=`pwd`
OUT_PATH=${FIBJS_PATH}/../../out
BIN_ROOT=${FIBJS_PATH}/../../bin
@@ -163,7 +163,7 @@ if [ ! -e ${OUT_PATH} ]; then
fi

cd ${OUT_PATH}
cmake -DBUILD_TYPE=${BUILD_TYPE} -DBUILD_OPTION="${BUILD_OPTION}" ${FIBJS_PATH} > CMake.log
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_TYPE=${BUILD_TYPE} -DBUILD_OPTION="${BUILD_OPTION}" ${FIBJS_PATH} > CMake.log
if [ $? != 0 ]; then
exit 1
fi
@@ -198,4 +198,4 @@ if [ "${BUILD_TYPE}" = "release" ]; then
fi
fi

cd "${FIBJS_PATH}"
cd "${FIBJS_PATH}"
@@ -1271,11 +1271,9 @@ describe('util', () => {
assert.property(util.buildInfo(), 'msvc');
break
case 'darwin':
assert.property(util.buildInfo(), 'clang');
break
case 'freebsd':
case 'linux':
assert.property(util.buildInfo(), 'gcc');
assert.property(util.buildInfo(), 'clang');
break
}
// git
2 vender
Submodule vender updated 1 files
+12 −23 build

0 comments on commit 5c3c59c

Please sign in to comment.
You can’t perform that action at this time.