Browse Source

Fix build of python on SGX (#41)

Don Porter 7 years ago
parent
commit
28585ad957

+ 3 - 1
LibOS/Makefile

@@ -6,7 +6,8 @@ export DEBUG
 GLIBC_SRC = glibc-2.19
 SHIM_DIR = shim
 BUILD_DIR = glibc-build
-GLIBC_TARGET = $(addprefix $(BUILD_DIR)/,libc.so.6 ld-linux-x86-64.so.2 libpthread.so.0 libm.so.6 libdl.so.2 libutil.so.1 crt1.o crti.o crtn.o liblibos.so.1)
+GLIBC_TARGET = $(addprefix $(BUILD_DIR)/,libc.so.6 ld-linux-x86-64.so.2 libpthread.so.0 libm.so.6 libdl.so.2 libutil.so.1 crt1.o crti.o crtn.o liblibos.so.1 libnss_dns.so.2 libresolv.so.2)
+
 
 all: $(GLIBC_TARGET)
 	$(MAKE) -C $(SHIM_DIR) all
@@ -38,6 +39,7 @@ pack: $(GLIBC_TARGET)
 clean:
 	$(MAKE) -C $(SHIM_DIR) clean
 	rm -rf $(BUILD_DIR)
+
 else
 $(GLIBC_TARGET): .packed/glibc.tar.gz
 	tar -xmozf $< $@

+ 2 - 0
LibOS/buildglibc.py

@@ -131,6 +131,8 @@ link_binaries     = [ ( 'elf',    'ld-linux-x86-64.so.2' ),
                       ( 'csu',    'crti.o' ),
                       ( 'csu',    'crtn.o' ),
                       ( 'rt',     'librt.so.1' ),
+                      ( 'resolv', 'libnss_dns.so.2' ),
+                      ( 'resolv', 'libresolv.so.2' ),
                       ( 'libos',  'liblibos.so.1' ) ]
 
 if True:

+ 8 - 2
LibOS/shim/test/Makefile

@@ -7,6 +7,12 @@ PALDIR  = $(level)../../../Pal/src
 SHIMDIR = $(level)../src
 RUNTIME = $(level)../../../Runtime
 
+ifeq ($(SGX),1)
+PAL_LOADER = pal_loader SGX
+else
+PAL_LOADER = pal_loader 
+endif
+
 CC = gcc
 CXX = g++
 CFLAGS 	= -std=gnu99
@@ -26,7 +32,7 @@ endif
 export DEBUG
 
 manifest_rules = \
-	-e 's:\$$(PAL):$(abspath $(RUNTIME)/pal_loader):g' \
+	-e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
 	-e 's:\$$(PWD):$(PWD):g' \
 	-e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
 	-e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
@@ -34,7 +40,7 @@ manifest_rules = \
 	$(extra_rules)
 
 pal_loader:
-	ln -s $(RUNTIME)/pal_loader
+	ln -sf $(RUNTIME)/pal_loader
 
 relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
 

+ 4 - 0
LibOS/shim/test/apps/python/Makefile

@@ -7,6 +7,7 @@ target = benchmarks
 exec_target = $(manifests)
 
 extra_rules = -e 's:\$$(PYTHONDIR):$(PYTHON_INSTALL)/:g'
+clean-extra += clean-tmp
 
 level = ../../
 include ../../Makefile
@@ -27,5 +28,8 @@ benchmarks: benchmarks.tar.gz
 
 BENCHMARK = all,-rietveld,-spitfire,-tornado_http
 
+clean-tmp:
+	rm -f python.manifest.sgx
+
 distclean: clean
 	rm -rf $(PYTHON_SRC) benchmarks

+ 2 - 2
LibOS/shim/test/apps/python/python.manifest.template

@@ -43,10 +43,10 @@ sgx.trusted_files.liburil = file:$(LIBCDIR)/libutil.so.1
 sgx.trusted_files.libz = file:/lib/x86_64-linux-gnu/libz.so.1
 sgx.trusted_files.libnss1 = file:/lib/x86_64-linux-gnu/libnss_compat.so.2
 sgx.trusted_files.libnss2 = file:/lib/x86_64-linux-gnu/libnss_files.so.2
-sgx.trusted_files.libnss3 = file:$(LIBCDIR)/resolv/libnss_dns.so.2
+sgx.trusted_files.libnss3 = file:$(LIBCDIR)/libnss_dns.so.2
 sgx.trusted_files.libssl = file:/lib/x86_64-linux-gnu/libssl.so.1.0.0
 sgx.trusted_files.libcrypto = file:/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
-sgx.trusted_files.libresolv = file:$(LIBCDIR)/resolv/libresolv.so.2
+sgx.trusted_files.libresolv = file:$(LIBCDIR)/libresolv.so.2
 sgx.trusted_files.hosts = file:hosts
 sgx.trusted_files.resolv = file:resolv.conf
 sgx.trusted_files.gai = file:gai.conf

+ 1 - 0
Makefile

@@ -13,6 +13,7 @@ endif
 $(targets):
 	$(MAKE) -C Pal $@
 	$(MAKE) -C LibOS $@
+	$(MAKE) -C Runtime $@
 
 .PHONY: install
 install:

+ 4 - 0
Runtime/Makefile

@@ -0,0 +1,4 @@
+clean:
+	rm -f libc.so.6 ld-linux-x86-64.so.2 libpthread.so.0 libm.so.6 libdl.so.2 libutil.so.1 crt1.o crti.o crtn.o liblibos.so.1 libnss_dns.so.2 libresolv.so.2 pal_gdb* pal-* pal_sec*
+
+all:

+ 5 - 0
Runtime/pal_loader

@@ -1,5 +1,10 @@
 #!/bin/bash
 
+if [ "$1" == "SGX" ]; then
+    export SGX=1
+    shift
+fi
+
 RUNTIME_DIR=$(/usr/bin/dirname $(readlink -f ${BASH_SOURCE[0]}))
 PAL_HOST=$(/usr/bin/make --quiet -f $RUNTIME_DIR/../Pal/src/Makefile.Host print_host 2>&1)