diff --git a/demos/hello_bazel/README.md b/demos/hello_bazel/README.md index 6d1e5018..ee125633 100644 --- a/demos/hello_bazel/README.md +++ b/demos/hello_bazel/README.md @@ -10,7 +10,7 @@ When completed, the resulting `hello-world` can be found in `examples/cpp-tutori 2. (Optional) Run `hello-world` on Linux ``` -LD_LIBRARY_PATH=/usr/local/occlum/x86_64-linux-musl/lib ./examples/cpp-tutorial/stage3/bazel-bin/main/hello-world +./examples/cpp-tutorial/stage3/bazel-bin/main/hello-world ``` 3. Run `hello-world` on Occlum diff --git a/demos/hello_bazel/build_bazel_sample.sh b/demos/hello_bazel/build_bazel_sample.sh index 430f8137..07128d39 100755 --- a/demos/hello_bazel/build_bazel_sample.sh +++ b/demos/hello_bazel/build_bazel_sample.sh @@ -7,4 +7,4 @@ git clone https://github.com/bazelbuild/examples/ . cd cpp-tutorial/stage3 export CC=/opt/occlum/toolchains/gcc/bin/occlum-gcc export CXX=/opt/occlum/toolchains/gcc/bin/occlum-g++ -bazel build --cxxopt=-std=c++11 --copt=-fPIC --linkopt=-pie //main:hello-world +bazel build --cxxopt=-std=c++11 //main:hello-world diff --git a/demos/hello_c/Makefile b/demos/hello_c/Makefile index 4feebba4..8da5427b 100644 --- a/demos/hello_c/Makefile +++ b/demos/hello_c/Makefile @@ -1,12 +1,11 @@ CC := occlum-gcc -CFLAGS := -fPIC -pie .PHONY: all clean all: hello_world hello_world: hello_world.c - $(CC) $(CFLAGS) $^ -o $@ + $(CC) $^ -o $@ clean: rm -rf hello_world diff --git a/demos/hello_c/README.md b/demos/hello_c/README.md index b19ae2b9..ec176334 100644 --- a/demos/hello_c/README.md +++ b/demos/hello_c/README.md @@ -9,7 +9,7 @@ make Or you can build `hello_world` with CMake ``` mkdir build && cd build -cmake ../ -DCMAKE_C_COMPILER=occlum-gcc -DCMAKE_C_FLAGS="-fPIC -pie" +cmake ../ -DCMAKE_C_COMPILER=occlum-gcc make cd .. cp build/hello_world . diff --git a/demos/hello_cc/Makefile b/demos/hello_cc/Makefile index 3e5bcc83..a86cfbdd 100644 --- a/demos/hello_cc/Makefile +++ b/demos/hello_cc/Makefile @@ -1,5 +1,5 @@ CXX := occlum-g++ -CXXFLAGS := -std=c++11 -fPIC -pie +CXXFLAGS := -std=c++11 .PHONY: all clean diff --git a/demos/hello_cc/README.md b/demos/hello_cc/README.md index a6be4f1d..9c98dcae 100644 --- a/demos/hello_cc/README.md +++ b/demos/hello_cc/README.md @@ -9,7 +9,7 @@ make Or you can build `hello_world` with CMake ``` mkdir build && cd build -cmake ../ -DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_CXX_FLAGS="-fPIC -pie" +cmake ../ -DCMAKE_CXX_COMPILER=occlum-g++ make cd .. cp build/hello_world . @@ -18,7 +18,7 @@ Either way, the resulting `hello_world` can be found in the current directory. 2. (Optional) Run `hello_world` on Linux ``` -LD_LIBRARY_PATH=/usr/local/occlum/x86_64-linux-musl/lib ./hello_world +./hello_world ``` 3. Run `hello_world` on Occlum diff --git a/demos/https_server/download_and_build_mongoose.sh b/demos/https_server/download_and_build_mongoose.sh index 89b28f96..aa27e3f4 100755 --- a/demos/https_server/download_and_build_mongoose.sh +++ b/demos/https_server/download_and_build_mongoose.sh @@ -10,8 +10,7 @@ CC=occlum-gcc ./config \ --prefix=/usr/local/occlum/x86_64-linux-musl \ --openssldir=/usr/local/occlum/ssl \ --with-rand-seed=rdcpu \ - no-zlib no-async no-tests \ - -fPIC -pie + no-zlib no-async no-tests make -j sudo make install popd @@ -25,5 +24,5 @@ popd # 3. Build the https server example in mongoose pushd mongoose_src/examples/simplest_web_server_ssl -CC=occlum-gcc CFLAGS_EXTRA="-Wno-format-truncation -fPIC -pie" make +CC=occlum-gcc CFLAGS_EXTRA="-Wno-format-truncation" make popd diff --git a/demos/https_server/run_https_server_in_linux.sh b/demos/https_server/run_https_server_in_linux.sh index 0f3e3c12..77233e95 100755 --- a/demos/https_server/run_https_server_in_linux.sh +++ b/demos/https_server/run_https_server_in_linux.sh @@ -1,5 +1,4 @@ #!/bin/bash -export LD_LIBRARY_PATH=/usr/local/occlum/x86_64-linux-musl/lib:$LD_LIBRARY_PATH https_server=simplest_web_server_ssl set -e diff --git a/demos/tensorflow_lite/patch/fix-tflite-Makefile-v1.15.0-rc0.diff b/demos/tensorflow_lite/patch/fix-tflite-Makefile-v1.15.0-rc0.diff index 389ca45d..77f77851 100644 --- a/demos/tensorflow_lite/patch/fix-tflite-Makefile-v1.15.0-rc0.diff +++ b/demos/tensorflow_lite/patch/fix-tflite-Makefile-v1.15.0-rc0.diff @@ -1,27 +1,8 @@ diff --git a/tensorflow/lite/tools/make/Makefile b/tensorflow/lite/tools/make/Makefile -index 73c50d3..3cef7fa 100644 +index 73c50d3..4a6445a 100644 --- a/tensorflow/lite/tools/make/Makefile +++ b/tensorflow/lite/tools/make/Makefile -@@ -42,7 +42,7 @@ INCLUDES := \ - -I$(OBJDIR) - # This is at the end so any globally-installed frameworks like protobuf don't - # override local versions in the source tree. --INCLUDES += -I/usr/local/include -+INCLUDES += -I/usr/local/occlum/x86_64-linux-musl/include - - # These are the default libraries needed, but they can be added to or - # overridden by the platform-specific settings in target makefiles. -@@ -59,7 +59,8 @@ CXXFLAGS := -O3 -DNDEBUG -fPIC - CXXFLAGS += $(EXTRA_CXXFLAGS) - CFLAGS := ${CXXFLAGS} - CXXFLAGS += --std=c++11 --LDOPTS := -L/usr/local/lib -+LDOPTS := -L/usr/local/occlum/x86_64-linux-musl/lib -+LDFLAGS := -pie $(LDOPTS) - ARFLAGS := -r - TARGET_TOOLCHAIN_PREFIX := - CC_PREFIX := -@@ -80,6 +81,12 @@ BENCHMARK_BINARY_NAME := benchmark_model +@@ -80,6 +80,12 @@ BENCHMARK_BINARY_NAME := benchmark_model MINIMAL_SRCS := \ tensorflow/lite/examples/minimal/minimal.cc @@ -34,7 +15,7 @@ index 73c50d3..3cef7fa 100644 # What sources we want to compile, must be kept in sync with the main Bazel # build files. -@@ -133,7 +140,8 @@ $(wildcard tensorflow/lite/*/*/*test.cc) \ +@@ -133,7 +139,8 @@ $(wildcard tensorflow/lite/*/*/*test.cc) \ $(wildcard tensorflow/lite/*/*/*/*test.cc) \ $(wildcard tensorflow/lite/kernels/*test_main.cc) \ $(wildcard tensorflow/lite/kernels/*test_util.cc) \ @@ -44,7 +25,7 @@ index 73c50d3..3cef7fa 100644 BUILD_WITH_MMAP ?= true ifeq ($(BUILD_TYPE),micro) -@@ -209,6 +217,7 @@ include $(wildcard $(MAKEFILE_DIR)/targets/*_makefile.inc) +@@ -209,6 +216,7 @@ include $(wildcard $(MAKEFILE_DIR)/targets/*_makefile.inc) ALL_SRCS := \ $(MINIMAL_SRCS) \ @@ -52,7 +33,7 @@ index 73c50d3..3cef7fa 100644 $(PROFILER_SRCS) \ $(PROFILER_SUMMARIZER_SRCS) \ $(TF_LITE_CC_SRCS) \ -@@ -225,14 +234,18 @@ LIB_PATH := $(LIBDIR)$(LIB_NAME) +@@ -225,14 +233,18 @@ LIB_PATH := $(LIBDIR)$(LIB_NAME) BENCHMARK_LIB := $(LIBDIR)$(BENCHMARK_LIB_NAME) BENCHMARK_BINARY := $(BINDIR)$(BENCHMARK_BINARY_NAME) MINIMAL_BINARY := $(BINDIR)minimal @@ -73,7 +54,7 @@ index 73c50d3..3cef7fa 100644 LIB_OBJS := $(addprefix $(OBJDIR), \ $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(TF_LITE_CC_SRCS))))) -@@ -252,7 +265,7 @@ $(OBJDIR)%.o: %.cpp +@@ -252,7 +264,7 @@ $(OBJDIR)%.o: %.cpp $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ # The target that's compiled if there's no command-line arguments. @@ -82,7 +63,7 @@ index 73c50d3..3cef7fa 100644 # The target that's compiled for micro-controllers micro: $(LIB_PATH) -@@ -276,6 +289,14 @@ $(MINIMAL_BINARY): $(MINIMAL_OBJS) $(LIB_PATH) +@@ -276,6 +288,14 @@ $(MINIMAL_BINARY): $(MINIMAL_OBJS) $(LIB_PATH) minimal: $(MINIMAL_BINARY) diff --git a/demos/tensorflow_lite/run_tflite_in_linux.sh b/demos/tensorflow_lite/run_tflite_in_linux.sh index 903ce90e..cce0e9d7 100755 --- a/demos/tensorflow_lite/run_tflite_in_linux.sh +++ b/demos/tensorflow_lite/run_tflite_in_linux.sh @@ -1,5 +1,4 @@ #!/bin/bash -export LD_LIBRARY_PATH=/usr/local/occlum/x86_64-linux-musl/lib:$LD_LIBRARY_PATH set -e show_usage() { diff --git a/tools/toolchains/gcc/build.sh b/tools/toolchains/gcc/build.sh index 908c4cf6..3c2033b5 100755 --- a/tools/toolchains/gcc/build.sh +++ b/tools/toolchains/gcc/build.sh @@ -47,9 +47,26 @@ make install # Remove all source code and build files rm -rf ${BUILD_DIR} -# Link the toolchain directory -ln -sf ${INSTALL_DIR}/bin/${TARGET}-gcc ${INSTALL_DIR}/bin/occlum-gcc -ln -sf ${INSTALL_DIR}/bin/${TARGET}-g++ ${INSTALL_DIR}/bin/occlum-g++ -ln -sf ${INSTALL_DIR}/bin/${TARGET}-ld ${INSTALL_DIR}/bin/occlum-ld -ln -sf ${INSTALL_DIR}/x86_64-linux-musl/lib/libc.so /lib/ld-musl-x86_64.so.1 +# Generate the wrappers for executables +cat > ${INSTALL_DIR}/bin/occlum-gcc < ${INSTALL_DIR}/bin/occlum-g++ < ${INSTALL_DIR}/bin/occlum-ld <