Skip to content

Commit

Permalink
[linux_build] bump to clang8|ue4.24, remove custom libcxx download an…
Browse files Browse the repository at this point in the history
…d build, add apt compiler flags and nuke the ones not needed anymore
  • Loading branch information
madratman committed Apr 1, 2020
1 parent c340b76 commit 1106a4e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 110 deletions.
27 changes: 3 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,6 @@ if $gccBuild; then
export CXX="g++"
fi
else
#check for correct verion of llvm
if [[ ! -d "llvm-source-50" ]]; then
if [[ -d "llvm-source-39" ]]; then
echo "Hello there! We just upgraded AirSim to Unreal Engine 4.24."
echo "Here are few easy steps for upgrade so everything is new and shiny :)"
echo "https://github.com/Microsoft/AirSim/blob/master/docs/unreal_upgrade.md"
exit 1
else
echo "The llvm-souce-50 folder was not found! Mystery indeed."
fi
fi

# check for libc++
if [[ !(-d "./llvm-build/output/lib") ]]; then
echo "ERROR: clang++ and libc++ is necessary to compile AirSim and run it in Unreal engine"
echo "Please run setup.sh first."
exit 1
fi

# variable for build output
build_dir=build_debug
if [ "$(uname)" == "Darwin" ]; then
Expand All @@ -94,8 +75,8 @@ else
fi

else
export CC="clang-5.0"
export CXX="clang++-5.0"
export CC="clang-8"
export CXX="clang++-8"
fi
fi

Expand Down Expand Up @@ -131,7 +112,6 @@ pushd $build_dir >/dev/null
make -j`nproc`
popd >/dev/null


mkdir -p AirLib/lib/x64/Debug
mkdir -p AirLib/deps/rpclib/lib
mkdir -p AirLib/deps/MavLinkCom/lib
Expand Down Expand Up @@ -165,5 +145,4 @@ echo "For help see:"
echo "https://github.com/Microsoft/AirSim/blob/master/docs/build_linux.md"
echo "=================================================================="


popd >/dev/null
popd >/dev/null
27 changes: 1 addition & 26 deletions cmake/cmake-modules/CommonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ macro(CommonSetup)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/output/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})

#libcxx which we will use with specific version of clang
SET(LIBCXX_INC_PATH ${AIRSIM_ROOT}/llvm-build/output/include/c++/v1)
SET(LIBCXX_LIB_PATH ${AIRSIM_ROOT}/llvm-build/output/lib)

#setup include and lib for rpclib which will be referenced by other projects
set(RPCLIB_VERSION_FOLDER rpclib-2.2.1)
set(RPC_LIB_INCLUDES " ${AIRSIM_ROOT}/external/rpclib/${RPCLIB_VERSION_FOLDER}/include")
Expand All @@ -58,36 +54,15 @@ macro(CommonSetup)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__CLANG__")
else ()
# other flags used in Unreal: -funwind-tables -fdiagnostics-format=msvc -fno-inline -Werror -fno-omit-frame-pointer -fstack-protector -O2
# TODO: add back -Wunused-parameter -Wno-documentation after rpclib can be compiled
set(CMAKE_CXX_FLAGS "\
-std=c++14 -ggdb -Wall -Wextra -Wstrict-aliasing -Wunreachable-code -Wcast-qual -Wctor-dtor-privacy \
-std=c++14 -stdlib=libc++ -ggdb -Wall -Wextra -Wstrict-aliasing -Wunreachable-code -Wcast-qual -Wctor-dtor-privacy \
-Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default \
-Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstrict-overflow=5 -Wswitch-default -Wundef \
-Wno-variadic-macros -Wno-parentheses -Wno-unused-function -Wno-unused -Wno-documentation -fdiagnostics-show-option \
-pthread \
${RPC_LIB_DEFINES} ${CMAKE_CXX_FLAGS}")

if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# make sure to match the compiler flags with which the Unreal
# Engine is built with
set(CMAKE_CXX_FLAGS "\
-nostdinc++ -ferror-limit=10 -isystem ${LIBCXX_INC_PATH} \
-D__CLANG__ ${CMAKE_CXX_FLAGS}")

# removed -lsupc++ from below (Git issue # 678)
set(CMAKE_EXE_LINKER_FLAGS "\
${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi -lm -lc \
-L ${LIBCXX_LIB_PATH} -rpath ${LIBCXX_LIB_PATH}")

#do not use experimental as it might potentially cause ABI issues
#set(CXX_EXP_LIB "-lc++experimental")

if("${BUILD_TYPE}" STREQUAL "debug")
# set same options that Unreal sets in debug builds
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funwind-tables -fdiagnostics-format=msvc -fno-inline -fno-omit-frame-pointer -fstack-protector")
endif()

else()
set(CXX_EXP_LIB "-lstdc++fs -fmax-errors=10 -Wnoexcept -Wstrict-null-sentinel")
endif ()
Expand Down
66 changes: 6 additions & 60 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
#! /bin/bash

if [[ -d "llvm-source-39" ]]; then
echo "Hello there! We just upgraded AirSim to Unreal Engine 4.24."
echo "Here are few easy steps for upgrade so everything is new and shiny :)"
echo "https://github.com/Microsoft/AirSim/blob/master/docs/unreal_upgrade.md"
exit 1
fi

set -x
# set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd "$SCRIPT_DIR" >/dev/null
Expand Down Expand Up @@ -60,7 +51,6 @@ if $gccBuild; then
else
# llvm tools
if [ "$(uname)" == "Darwin" ]; then # osx

if [[ -n $CIINSTALL ]]; then # use downloaded binaries on Travis
export C_COMPILER=${LLVM_DIR}/bin/clang
export COMPILER=${LLVM_DIR}/bin/clang++
Expand All @@ -69,24 +59,19 @@ else

# brew install llvm@3.9
brew tap llvm-hs/homebrew-llvm
brew install llvm-5.0
export C_COMPILER=/usr/local/opt/llvm-5.0/bin/clang-5.0
export COMPILER=/usr/local/opt/llvm-5.0/bin/clang++-5.0
brew install llvm-8.0
fi

else #linux
#install clang and build tools

VERSION=$(lsb_release -rs | cut -d. -f1)
# Since Ubuntu 17 clang-5.0 is part of the core repository
# See https://packages.ubuntu.com/search?keywords=clang-5.0
# Since Ubuntu 17 clang is part of the core repository
# See https://packages.ubuntu.com/search?keywords=clang-8
if [ "$VERSION" -lt "17" ]; then
wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
fi
sudo apt-get install -y clang-5.0 clang++-5.0
export C_COMPILER=clang-5.0
export COMPILER=clang++-5.0
sudo apt-get install -y clang-8 clang++-8 libc++-8-dev libc++abi-8-dev
fi
fi

Expand Down Expand Up @@ -189,45 +174,6 @@ else
echo "### Not downloading high-poly car asset (--no-full-poly-car). The default unreal vehicle will be used."
fi

# Below is alternative way to get clang by downloading binaries
# get clang, libc++
# sudo rm -rf llvm-build
# mkdir -p llvm-build/output
# wget "http://releases.llvm.org/4.0.1/clang+llvm-4.0.1-x86_64-linux-gnu-debian8.tar.xz"
# tar -xf "clang+llvm-4.0.1-x86_64-linux-gnu-debian8.tar.xz" -C llvm-build/output

# #other packages - not need for now
# #sudo apt-get install -y clang-3.9-doc libclang-common-3.9-dev libclang-3.9-dev libclang1-3.9 libclang1-3.9-dbg libllvm-3.9-ocaml-dev libllvm3.9 libllvm3.9-dbg lldb-3.9 llvm-3.9 llvm-3.9-dev llvm-3.9-doc llvm-3.9-examples llvm-3.9-runtime clang-format-3.9 python-clang-3.9 libfuzzer-3.9-dev

#get libc++ source
if ! $gccBuild; then
echo "### Installing llvm 5 libc++ library..."
if [[ ! -d "llvm-source-50" ]]; then
git clone --depth=1 -b release_50 https://github.com/llvm-mirror/llvm.git llvm-source-50
git clone --depth=1 -b release_50 https://github.com/llvm-mirror/libcxx.git llvm-source-50/projects/libcxx
git clone --depth=1 -b release_50 https://github.com/llvm-mirror/libcxxabi.git llvm-source-50/projects/libcxxabi
else
echo "folder llvm-source-50 already exists, skipping git clone..."
fi

# build libc++
rm -rf llvm-build
mkdir -p llvm-build
pushd llvm-build >/dev/null

"$CMAKE" -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
-LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=./output \
../llvm-source-50

make cxx -j`nproc`

# install libc++ locally in output folder
make install-libcxx install-libcxxabi

popd >/dev/null
fi

echo "Installing EIGEN library..."

rm -rf ./AirLib/deps/eigen3/Eigen
Expand All @@ -245,4 +191,4 @@ set +x
echo ""
echo "************************************"
echo "AirSim setup completed successfully!"
echo "************************************"
echo "************************************"

0 comments on commit 1106a4e

Please sign in to comment.