Add support for compiling C code as well as Rust in release mode
We can now build all source code (.S, .c, and .rs) under `src/` in release mode with `OCCLUM_RELEASE_BUILD=1 make` command.
This commit is contained in:
parent
d825351f02
commit
671da280d8
@ -33,9 +33,6 @@ include ../sgxenv.mk
|
||||
# | +---------------| |
|
||||
# +-------------------+
|
||||
|
||||
# Build LibOS in debug or release mode
|
||||
LIBOS_RELEASE ?= 0
|
||||
|
||||
# The log level for LibOS
|
||||
#
|
||||
# There are five levels:
|
||||
@ -117,14 +114,14 @@ $(LIBOS_CORE_A): $(LIBOS_CORE_RS_A) $(C_OBJS) $(CXX_OBJS) $(S_OBJS) $(EDL_C_OBJS
|
||||
@ar r $@ $(C_OBJS) $(CXX_OBJS) $(S_OBJS) $(EDL_C_OBJS)
|
||||
@echo "GEN => $@"
|
||||
|
||||
ifeq ($(LIBOS_RELEASE), 0)
|
||||
$(LIBOS_CORE_RS_A): $(RUST_SRCS)
|
||||
@RUSTC_BOOTSTRAP=1 cargo build --target-dir=$(RUST_TARGET_DIR) -Z unstable-options --out-dir=$(RUST_OUT_DIR)
|
||||
@echo "CARGO (debug) => $@"
|
||||
else
|
||||
ifeq ($(OCCLUM_RELEASE_BUILD), 1)
|
||||
$(LIBOS_CORE_RS_A): $(RUST_SRCS)
|
||||
@RUSTC_BOOTSTRAP=1 cargo build --release --target-dir=$(RUST_TARGET_DIR) -Z unstable-options --out-dir=$(RUST_OUT_DIR)
|
||||
@echo "CARGO (release) => $@"
|
||||
else
|
||||
$(LIBOS_CORE_RS_A): $(RUST_SRCS)
|
||||
@RUSTC_BOOTSTRAP=1 cargo build --target-dir=$(RUST_TARGET_DIR) -Z unstable-options --out-dir=$(RUST_OUT_DIR)
|
||||
@echo "CARGO (debug) => $@"
|
||||
endif
|
||||
|
||||
$(BUILD_DIR)/src/libos/src/Enclave_t.o: $(BUILD_DIR)/src/libos/src/Enclave_t.c
|
||||
|
@ -8,6 +8,14 @@ SGX_SDK ?= /opt/intel/sgxsdk
|
||||
SGX_MODE ?= HW
|
||||
SGX_ARCH ?= x64
|
||||
|
||||
# If OCCLUM_RELEASE_BUILD equals to 1, y, or yes, then build in release mode
|
||||
OCCLUM_RELEASE_BUILD ?= 0
|
||||
ifeq ($(OCCLUM_RELEASE_BUILD), yes)
|
||||
OCCLUM_RELEASE_BUILD := 1
|
||||
else ifeq ($(OCCLUM_RELEASE_BUILD), y)
|
||||
OCCLUM_RELEASE_BUILD := 1
|
||||
endif
|
||||
|
||||
ifeq ($(shell getconf LONG_BIT), 32)
|
||||
SGX_ARCH := x86
|
||||
else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32)
|
||||
@ -28,16 +36,10 @@ else
|
||||
SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r
|
||||
endif
|
||||
|
||||
ifeq ($(SGX_DEBUG), 1)
|
||||
ifeq ($(SGX_PRERELEASE), 1)
|
||||
$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(SGX_DEBUG), 1)
|
||||
SGX_COMMON_CFLAGS += -O0 -g
|
||||
else
|
||||
ifeq ($(OCCLUM_RELEASE_BUILD), 1)
|
||||
SGX_COMMON_CFLAGS += -O2
|
||||
else
|
||||
SGX_COMMON_CFLAGS += -O0 -g
|
||||
endif
|
||||
|
||||
RUST_SGX_SDK_DIR := $(PROJECT_DIR)/deps/rust-sgx-sdk
|
||||
|
@ -87,7 +87,7 @@ WORKDIR /root
|
||||
RUN git clone https://github.com/occlum/occlum && \
|
||||
cd occlum && \
|
||||
make submodule && \
|
||||
make LIBOS_RELEASE=1 && \
|
||||
OCCLUM_RELEASE_BUILD=1 make && \
|
||||
make install && \
|
||||
cp -r demos /root/demos && \
|
||||
rm -rf /root/occlum
|
||||
|
@ -77,7 +77,7 @@ WORKDIR /root
|
||||
RUN git clone https://github.com/occlum/occlum && \
|
||||
cd occlum && \
|
||||
make submodule && \
|
||||
make LIBOS_RELEASE=1 && \
|
||||
OCCLUM_RELEASE_BUILD=1 make && \
|
||||
make install && \
|
||||
cp -r demos /root/demos && \
|
||||
rm -rf /root/occlum
|
||||
|
@ -79,7 +79,7 @@ WORKDIR /root
|
||||
RUN git clone https://github.com/occlum/occlum && \
|
||||
cd occlum && \
|
||||
make submodule && \
|
||||
make LIBOS_RELEASE=1 && \
|
||||
OCCLUM_RELEASE_BUILD=1 make && \
|
||||
make install && \
|
||||
cp -r demos /root/demos && \
|
||||
rm -rf /root/occlum
|
||||
|
Loading…
Reference in New Issue
Block a user