Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Allow eosiocpp to run without make install #5206

Merged
merged 1 commit into from
Aug 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 47 additions & 12 deletions tools/eosiocpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@ if [ "${EOSIO_BIN_INSTALL_DIR}" == "." ]; then
EOSIO_BIN_INSTALL_DIR=`pwd`
fi
EOSIO_INSTALL_DIR=`dirname ${EOSIO_BIN_INSTALL_DIR}`
ABIGEN=${EOSIO_INSTALL_DIR}/bin/eosio-abigen
if [ -x "@CMAKE_BINARY_DIR@/programs/eosio-abigen/eosio-abigen" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry about packaging and installing a script that has the full CMAKE_BINARY_DIR in the resulting file. Won't that leak some information that could be considered sensitive about the system that built the binary package (like user name of the builder etc).

Can we do something where it discovers all of these paths relative to the directory where the script resides so that we don't have to hard code the absolute path? I realize this makes eosiocpp fragile when you copy/move it around but, that seems like a better trade?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could leak information depending on how it's built. It does not have to be sensitive information, especially on dedicated build boxes. At present, we're not distributing any package format except Docker, which I don't think carries ownership or a home directory path within it. Finally, this is a stopgap until the wasmsdk repo is ready for prime time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, docker should do a decent job of sanitizing paths... I'm checking right now and will release my objection if it looks benign.

ABIGEN="@CMAKE_BINARY_DIR@/programs/eosio-abigen/eosio-abigen"
elif [ -x "${EOSIO_INSTALL_DIR}/bin/eosio-abigen" ]; then
ABIGEN=${EOSIO_INSTALL_DIR}/bin/eosio-abigen
fi
if [ -x "@CMAKE_BINARY_DIR@/externals/binaryen/bin/eosio-s2wasm" ]; then
EOSIO_S2WASM="@CMAKE_BINARY_DIR@/externals/binaryen/bin/eosio-s2wasm"
elif [ -x "${EOSIO_INSTALL_DIR}/bin/eosio-s2wasm" ]; then
EOSIO_S2WASM="${EOSIO_INSTALL_DIR}/bin/eosio-s2wasm"
else
echo "eosio-s2wasm not found either built or installed"
exit 12
fi
if [ -x "@CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Programs/eosio-wast2wasm" ]; then
EOSIO_WAST2WASM="@CMAKE_BINARY_DIR@/libraries/wasm-jit/Source/Programs/eosio-wast2wasm"
elif [ -x "${EOSIO_INSTALL_DIR}/bin/eosio-wast2wasm" ]; then
EOSIO_WAST2WASM="${EOSIO_INSTALL_DIR}/bin/eosio-wast2wasm"
else
echo "eosio-wast2wasm not found either built or installed"
exit 14
fi
BOOST_INCLUDE_DIR=@Boost_INCLUDE_DIR@
function copy_skeleton {
set -e
Expand Down Expand Up @@ -41,8 +61,13 @@ function build_contract {

($PRINT_CMDS; @WASM_CLANG@ -emit-llvm -O3 --std=c++14 --target=wasm32 -nostdinc \
-DBOOST_DISABLE_ASSERTS -DBOOST_EXCEPTION_DISABLE \
-nostdlib -nostdlibinc -ffreestanding -nostdlib -fno-threadsafe-statics -fno-rtti \
-fno-exceptions -I ${EOSIO_INSTALL_DIR}/include \
-nostdlib -nostdlibinc -ffreestanding -nostdlib \
-fno-threadsafe-statics -fno-rtti -fno-exceptions \
-I @CMAKE_SOURCE_DIR@/contracts \
-I @CMAKE_SOURCE_DIR@/contracts/libc++/upstream/include \
-I @CMAKE_SOURCE_DIR@/contracts/musl/upstream/include \
-I @CMAKE_SOURCE_DIR@/externals/magic_get/include \
-I ${EOSIO_INSTALL_DIR}/include \
-I${EOSIO_INSTALL_DIR}/include/libc++/upstream/include \
-I${EOSIO_INSTALL_DIR}/include/musl/upstream/include \
-I${BOOST_INCLUDE_DIR} \
Expand All @@ -53,16 +78,22 @@ function build_contract {

done

($PRINT_CMDS; @WASM_LLVM_LINK@ -only-needed -o $workdir/linked.bc $workdir/built/* \
${EOSIO_INSTALL_DIR}/usr/share/eosio/contractsdk/lib/eosiolib.bc \
${EOSIO_INSTALL_DIR}/usr/share/eosio/contractsdk/lib/libc++.bc \
${EOSIO_INSTALL_DIR}/usr/share/eosio/contractsdk/lib/libc.bc


)
declare -a possible_libs=("@CMAKE_BINARY_DIR@/contracts/eosiolib/eosiolib.bc"
"@CMAKE_BINARY_DIR@/contracts/libc++/libc++.bc"
"@CMAKE_BINARY_DIR@/contracts/musl/libc.bc"
"${EOSIO_INSTALL_DIR}/usr/share/eosio/contractsdk/lib/eosiolib.bc"
"${EOSIO_INSTALL_DIR}/usr/share/eosio/contractsdk/lib/libc++.bc"
"${EOSIO_INSTALL_DIR}/usr/share/eosio/contractsdk/lib/libc.bc")
declare libs=""
for lib in "${possible_libs[@]}"; do
if [ -f "${lib}" ]; then
libs="${libs} ${lib}"
fi
done
($PRINT_CMDS; @WASM_LLVM_LINK@ -only-needed -o $workdir/linked.bc $workdir/built/* ${libs})
($PRINT_CMDS; @WASM_LLC@ -thread-model=single --asm-verbose=false -o $workdir/assembly.s $workdir/linked.bc)
($PRINT_CMDS; ${EOSIO_INSTALL_DIR}/bin/eosio-s2wasm -o $outname -s 16384 $workdir/assembly.s)
($PRINT_CMDS; ${EOSIO_INSTALL_DIR}/bin/eosio-wast2wasm $outname ${outname%.*}.wasm -n)
($PRINT_CMDS; ${EOSIO_S2WASM} -o $outname -s 16384 $workdir/assembly.s)
($PRINT_CMDS; ${EOSIO_WAST2WASM} $outname ${outname%.*}.wasm -n)

($PRINT_CMDS; rm -rf $workdir)
set +e
Expand All @@ -79,6 +110,10 @@ function generate_abi {

${ABIGEN} -extra-arg=-c -extra-arg=--std=c++14 -extra-arg=--target=wasm32 \
-extra-arg=-nostdinc -extra-arg=-nostdinc++ -extra-arg=-DABIGEN \
-extra-arg=-I@CMAKE_SOURCE_DIR@/contracts \
-extra-arg=-I@CMAKE_SOURCE_DIR@/contracts/libc++/upstream/include \
-extra-arg=-I@CMAKE_SOURCE_DIR@/contracts/musl/upstream/include \
-extra-arg=-I@CMAKE_SOURCE_DIR@/externals/magic_get/include \
-extra-arg=-I${EOSIO_INSTALL_DIR}/include/libc++/upstream/include \
-extra-arg=-I${EOSIO_INSTALL_DIR}/include/musl/upstream/include \
-extra-arg=-I${BOOST_INCLUDE_DIR} \
Expand Down