Commit c4ed549e by Jim Stichnoth

Subzero: Build sandboxed translators for the browser.

Along with the nexe equivalents of pnacl-sz, also build the browser-integrated versions that can be dropped in as replacements. Note that these are not exact replacements, as they likely support all targets. In "make presubmit", instead build sandboxed translators in DEBUG=1 mode, so they can build in parallel with the assembler unit tests. Add a "make bloat-sb" target that does the "make bloat" equivalent for the sandboxed translators. BUG= none R=jpp@chromium.org Review URL: https://codereview.chromium.org/1746593002 .
parent 7de95ea1
...@@ -92,9 +92,6 @@ else ...@@ -92,9 +92,6 @@ else
-DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_MINIMAL_BUILD=0 -DALLOW_LLVM_IR_AS_INPUT=1 -DALLOW_MINIMAL_BUILD=0
endif endif
# TODO(stichnot): Also work up a -DPNACL_BROWSER_TRANSLATOR=1 version of a
# sandboxed translator.
SB_CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0
CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0 CXX_DEFINES := $(BASE_CXX_DEFINES) -DPNACL_BROWSER_TRANSLATOR=0
ifdef NOASSERT ifdef NOASSERT
...@@ -156,6 +153,7 @@ else ...@@ -156,6 +153,7 @@ else
endif endif
SB_OBJDIR := $(OBJDIR)+Sandboxed SB_OBJDIR := $(OBJDIR)+Sandboxed
SBB_OBJDIR := $(OBJDIR)+SandboxedBrowser
$(info -----------------------------------------------) $(info -----------------------------------------------)
$(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH)) $(info Using LLVM_SRC_PATH = $(LLVM_SRC_PATH))
...@@ -235,8 +233,8 @@ BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \ ...@@ -235,8 +233,8 @@ BASE_CXXFLAGS := -std=gnu++11 -Wall -Wextra -Werror -fno-rtti \
CXXFLAGS := $(LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(CXX_DEFINES) $(HOST_FLAGS) \ CXXFLAGS := $(LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(CXX_DEFINES) $(HOST_FLAGS) \
$(STDLIB_FLAGS) $(STDLIB_FLAGS)
SB_CXXFLAGS := $(SB_LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(SB_CXX_DEFINES) \ SB_CXXFLAGS := $(SB_LLVM_CXXFLAGS) $(BASE_CXXFLAGS) $(BASE_CXX_DEFINES) \
-Wno-unknown-pragmas -I$(NACL_ROOT) -Wno-unknown-pragmas -I$(NACL_ROOT) -I$(NACL_ROOT)/..
LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib -Wl,--gc-sections \ LDFLAGS := $(HOST_FLAGS) -L$(LIBCXX_INSTALL_PATH)/lib -Wl,--gc-sections \
$(LD_EXTRA) $(STDLIB_FLAGS) $(LD_EXTRA) $(STDLIB_FLAGS)
...@@ -293,6 +291,7 @@ endif ...@@ -293,6 +291,7 @@ endif
OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS)) OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
SB_OBJS=$(patsubst %.cpp, $(SB_OBJDIR)/%.o, $(SRCS)) SB_OBJS=$(patsubst %.cpp, $(SB_OBJDIR)/%.o, $(SRCS))
SBB_OBJS=$(patsubst %.cpp, $(SBB_OBJDIR)/%.o, $(SRCS))
UNITTEST_SRCS = \ UNITTEST_SRCS = \
BitcodeMunge.cpp \ BitcodeMunge.cpp \
...@@ -325,6 +324,11 @@ endif ...@@ -325,6 +324,11 @@ endif
UNITTEST_OBJS = $(patsubst %.cpp, $(OBJDIR)/unittest/%.o, $(UNITTEST_SRCS)) UNITTEST_OBJS = $(patsubst %.cpp, $(OBJDIR)/unittest/%.o, $(UNITTEST_SRCS))
UNITTEST_LIB_OBJS = $(filter-out $(OBJDIR)/main.o,$(OBJS)) UNITTEST_LIB_OBJS = $(filter-out $(OBJDIR)/main.o,$(OBJS))
NEXES = $(SB_OBJDIR)/pnacl-sz.x8632.nexe \
$(SB_OBJDIR)/pnacl-sz.x8664.nexe \
$(SBB_OBJDIR)/pnacl_public_x86_32_pnacl_sz_nexe \
$(SBB_OBJDIR)/pnacl_public_x86_64_pnacl_sz_nexe
# Keep all the first target so it's the default. # Keep all the first target so it's the default.
all: $(OBJDIR)/pnacl-sz make_symlink runtime all: $(OBJDIR)/pnacl-sz make_symlink runtime
...@@ -332,9 +336,7 @@ ifdef TSAN ...@@ -332,9 +336,7 @@ ifdef TSAN
sb: sb:
@echo "Skipping pnacl-sz.*.nexe: TSAN isn't supported under NaCl." @echo "Skipping pnacl-sz.*.nexe: TSAN isn't supported under NaCl."
else else
sb: $(SB_OBJDIR)/pnacl-sz.x8632.nexe \ sb: $(NEXES) sb_make_symlink
$(SB_OBJDIR)/pnacl-sz.x8664.nexe \
sb_make_symlink
endif endif
# SHOW_BUILD_ATTS is an executable that is run to show what build # SHOW_BUILD_ATTS is an executable that is run to show what build
...@@ -350,11 +352,11 @@ make_symlink: $(OBJDIR)/pnacl-sz ...@@ -350,11 +352,11 @@ make_symlink: $(OBJDIR)/pnacl-sz
@echo "Build Attributes:" @echo "Build Attributes:"
@$(SHOW_BUILD_ATTS) @$(SHOW_BUILD_ATTS)
sb_make_symlink: $(SB_OBJDIR)/pnacl-sz.x8632.nexe \ sb_make_symlink: $(NEXES)
$(SB_OBJDIR)/pnacl-sz.x8664.nexe $(foreach nexe,$(NEXES),rm -rf $(notdir $(nexe)); ln -s $(nexe);)
rm -rf pnacl-sz.x8632.nexe pnacl-sz.x8664.nexe
ln -s $(SB_OBJDIR)/pnacl-sz.x8632.nexe %.pexe : %.nonfinal.pexe
ln -s $(SB_OBJDIR)/pnacl-sz.x8664.nexe $(SB_FINALIZE) -o $@ $<
.PHONY: all compile_only make_symlink runtime bloat sb docs help \ .PHONY: all compile_only make_symlink runtime bloat sb docs help \
help-check-lit help-check-xtest help-check-lit help-check-xtest
...@@ -368,8 +370,9 @@ $(OBJDIR)/pnacl-sz: $(OBJS) ...@@ -368,8 +370,9 @@ $(OBJDIR)/pnacl-sz: $(OBJS)
$(SB_OBJDIR)/pnacl-sz.nonfinal.pexe: $(SB_OBJS) $(SB_OBJDIR)/pnacl-sz.nonfinal.pexe: $(SB_OBJS)
$(SB_CXX) $(SB_LDFLAGS) -o $@ $^ $(SB_LLVM_LDFLAGS) $(SB_CXX) $(SB_LDFLAGS) -o $@ $^ $(SB_LLVM_LDFLAGS)
$(SB_OBJDIR)/pnacl-sz.pexe: $(SB_OBJDIR)/pnacl-sz.nonfinal.pexe $(SBB_OBJDIR)/pnacl-sz.nonfinal.pexe: $(SBB_OBJS)
$(SB_FINALIZE) $^ -o $@ $(SB_CXX) $(SB_LDFLAGS) -o $@ $^ $(SB_LLVM_LDFLAGS) \
--pnacl-disable-abi-check
$(SB_OBJDIR)/pnacl-sz.x8632.nexe: $(SB_OBJDIR)/pnacl-sz.pexe $(SB_OBJDIR)/pnacl-sz.x8632.nexe: $(SB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-32 $^ -o $@ $(SB_TRANSLATE) -arch x86-32 $^ -o $@
...@@ -377,6 +380,12 @@ $(SB_OBJDIR)/pnacl-sz.x8632.nexe: $(SB_OBJDIR)/pnacl-sz.pexe ...@@ -377,6 +380,12 @@ $(SB_OBJDIR)/pnacl-sz.x8632.nexe: $(SB_OBJDIR)/pnacl-sz.pexe
$(SB_OBJDIR)/pnacl-sz.x8664.nexe: $(SB_OBJDIR)/pnacl-sz.pexe $(SB_OBJDIR)/pnacl-sz.x8664.nexe: $(SB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-64 $^ -o $@ $(SB_TRANSLATE) -arch x86-64 $^ -o $@
$(SBB_OBJDIR)/pnacl_public_x86_32_pnacl_sz_nexe: $(SBB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-32 $^ -o $@
$(SBB_OBJDIR)/pnacl_public_x86_64_pnacl_sz_nexe: $(SBB_OBJDIR)/pnacl-sz.pexe
$(SB_TRANSLATE) -arch x86-64 $^ -o $@
src/IceRegistersARM32.def: pydir/gen_arm32_reg_tables.py src/IceRegistersARM32.def: pydir/gen_arm32_reg_tables.py
python $< > $@ python $< > $@
...@@ -385,7 +394,10 @@ $(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def ...@@ -385,7 +394,10 @@ $(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
$(CXX) -c $(CXXFLAGS) $< -o $@ $(CXX) -c $(CXXFLAGS) $< -o $@
$(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def $(SB_OBJS): $(SB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
$(SB_CXX) -c $(SB_CXXFLAGS) $< -o $@ $(SB_CXX) -c $(SB_CXXFLAGS) -DPNACL_BROWSER_TRANSLATOR=0 $< -o $@
$(SBB_OBJS): $(SBB_OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
$(SB_CXX) -c $(SB_CXXFLAGS) -DPNACL_BROWSER_TRANSLATOR=1 $< -o $@
$(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS) $(OBJDIR)/run_unittests: $(UNITTEST_OBJS) $(UNITTEST_LIB_OBJS)
$(CXX) $(GTEST_LIB_PATH) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \ $(CXX) $(GTEST_LIB_PATH) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) \
...@@ -404,6 +416,7 @@ $(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp unittest/*.h \ ...@@ -404,6 +416,7 @@ $(UNITTEST_OBJS): $(OBJDIR)/unittest/%.o: unittest/%.cpp unittest/*.h \
$(OBJS): | $(OBJDIR) $(OBJS): | $(OBJDIR)
$(SB_OBJS): | $(SB_OBJDIR) $(SB_OBJS): | $(SB_OBJDIR)
$(SBB_OBJS): | $(SBB_OBJDIR)
$(UNITTEST_OBJS): | $(OBJDIR)/unittest $(OBJDIR)/unittest/AssemblerX8632 \ $(UNITTEST_OBJS): | $(OBJDIR)/unittest $(OBJDIR)/unittest/AssemblerX8632 \
$(OBJDIR)/unittest/AssemblerX8664 $(OBJDIR)/unittest/AssemblerX8664
...@@ -412,6 +425,8 @@ $(OBJDIR): ...@@ -412,6 +425,8 @@ $(OBJDIR):
@mkdir -p $@ @mkdir -p $@
$(SB_OBJDIR): $(SB_OBJDIR):
@mkdir -p $@ @mkdir -p $@
$(SBB_OBJDIR):
@mkdir -p $@
$(OBJDIR)/unittest: $(OBJDIR) $(OBJDIR)/unittest: $(OBJDIR)
@mkdir -p $@ @mkdir -p $@
...@@ -516,13 +531,13 @@ check-presubmit presubmit: ...@@ -516,13 +531,13 @@ check-presubmit presubmit:
+make -f Makefile.standalone format +make -f Makefile.standalone format
# Verify MINIMAL build, plus proper usage of REQUIRES in lit tests. # Verify MINIMAL build, plus proper usage of REQUIRES in lit tests.
+make -f Makefile.standalone \ +make -f Makefile.standalone \
MINIMAL=1 sb check MINIMAL=1 check
# Check that there are no g++ build errors or warnings. # Check that there are no g++ build errors or warnings.
+make -f Makefile.standalone \ +make -f Makefile.standalone \
GPLUSPLUS=1 compile_only GPLUSPLUS=1 compile_only
# Check the x86 assembler unit tests. # Check the x86 assembler unit tests.
+make -f Makefile.standalone \ +make -f Makefile.standalone \
DEBUG=1 CHECK_X86_ASM=1 check-unit DEBUG=1 CHECK_X86_ASM=1 check-unit sb
# Run lit tests, cross tests, unit tests, and spec2k/x86-32. # Run lit tests, cross tests, unit tests, and spec2k/x86-32.
+make -f Makefile.standalone \ +make -f Makefile.standalone \
check check-spec sb check check-spec sb
...@@ -578,6 +593,12 @@ bloat: make_symlink ...@@ -578,6 +593,12 @@ bloat: make_symlink
bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json bloat/bloat.py --nm-output=/dev/stdin syms > build/pnacl-sz.bloat.json
@echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html @echo See Subzero size breakdown in bloat/pnacl-sz.bloat.html
bloat-sb: sb_make_symlink
$(foreach nexe,$(NEXES),nm -C -S -l $(nexe) | bloat/bloat.py \
--nm-output=/dev/stdin syms > build/$(notdir $(nexe)).bloat.json;)
@echo "See Subzero size breakdown in:"
@$(foreach nexe,$(NEXES),echo " bloat/$(notdir $(nexe)).bloat.html";)
docs: docs:
make -C docs -f Makefile.standalone make -C docs -f Makefile.standalone
...@@ -591,8 +612,8 @@ help-check-xtest: ...@@ -591,8 +612,8 @@ help-check-xtest:
@cat Makefile.standalone-help/check-xtest.txt @cat Makefile.standalone-help/check-xtest.txt
clean: clean:
rm -rf pnacl-sz pnacl-sz.x8632.nexe pnacl-sz.x8664.nexe *.o \ rm -rf pnacl-sz *.o $(foreach nexe,$(NEXES),$(notdir $(nexe))) \
$(OBJDIR) $(SB_OBJDIR) build/pnacl-sz.bloat.json $(OBJDIR) $(SB_OBJDIR) $(SBB_OBJDIR) build/*.bloat.json
clean-all: clean clean-all: clean
rm -rf build/ crosstest/Output/ rm -rf build/ crosstest/Output/
<!DOCTYPE html>
<head>
<title>Subzero size breakdown</title>
<script src='../build/pnacl-sz.x8632.nexe.bloat.json'></script>
<link rel='stylesheet' href='webtreemap.css'>
<style>
body {
font-family: sans-serif;
font-size: 0.8em;
margin: 2ex 4ex;
}
h1 {
font-weight: normal;
}
#map {
height: 70vh;
position: relative;
cursor: pointer;
-webkit-user-select: none;
}
#legend {
width: 200px;
}
</style>
</head>
<body>
<h1>Subzero size breakdown</h1>
<p>Click on a box to zoom in. Click on the outermost box to zoom out.</p>
<div id='map'></div>
<script src='webtreemap.js'></script>
<script>
var map = document.getElementById('map');
appendTreemap(map, kTree);
</script>
<div id='legend'>
<div class='webtreemap-symbol-bss'>bss</div>
<div class='webtreemap-symbol-bss webtreemap-aggregate'>bss aggregate</div>
<div class='webtreemap-symbol-data'>data</div>
<div class='webtreemap-symbol-data webtreemap-aggregate'>data aggregate</div>
<div class='webtreemap-symbol-read-only_data'>read-only data</div>
<div class='webtreemap-symbol-read-only_data webtreemap-aggregate'>read-only
data aggregate</div>
<div class='webtreemap-symbol-code'>code</div>
<div class='webtreemap-symbol-code webtreemap-aggregate'>code aggregate</div>
<div class='webtreemap-symbol-weak_symbol'>weak symbol</div>
<div class='webtreemap-symbol-weak_symbol webtreemap-aggregate'>weak symbol
aggregate</div>
</div>
</body>
<!DOCTYPE html>
<head>
<title>Subzero size breakdown</title>
<script src='../build/pnacl-sz.x8664.nexe.bloat.json'></script>
<link rel='stylesheet' href='webtreemap.css'>
<style>
body {
font-family: sans-serif;
font-size: 0.8em;
margin: 2ex 4ex;
}
h1 {
font-weight: normal;
}
#map {
height: 70vh;
position: relative;
cursor: pointer;
-webkit-user-select: none;
}
#legend {
width: 200px;
}
</style>
</head>
<body>
<h1>Subzero size breakdown</h1>
<p>Click on a box to zoom in. Click on the outermost box to zoom out.</p>
<div id='map'></div>
<script src='webtreemap.js'></script>
<script>
var map = document.getElementById('map');
appendTreemap(map, kTree);
</script>
<div id='legend'>
<div class='webtreemap-symbol-bss'>bss</div>
<div class='webtreemap-symbol-bss webtreemap-aggregate'>bss aggregate</div>
<div class='webtreemap-symbol-data'>data</div>
<div class='webtreemap-symbol-data webtreemap-aggregate'>data aggregate</div>
<div class='webtreemap-symbol-read-only_data'>read-only data</div>
<div class='webtreemap-symbol-read-only_data webtreemap-aggregate'>read-only
data aggregate</div>
<div class='webtreemap-symbol-code'>code</div>
<div class='webtreemap-symbol-code webtreemap-aggregate'>code aggregate</div>
<div class='webtreemap-symbol-weak_symbol'>weak symbol</div>
<div class='webtreemap-symbol-weak_symbol webtreemap-aggregate'>weak symbol
aggregate</div>
</div>
</body>
<!DOCTYPE html>
<head>
<title>Subzero size breakdown</title>
<script src='../build/pnacl_public_x86_32_pnacl_sz_nexe.bloat.json'></script>
<link rel='stylesheet' href='webtreemap.css'>
<style>
body {
font-family: sans-serif;
font-size: 0.8em;
margin: 2ex 4ex;
}
h1 {
font-weight: normal;
}
#map {
height: 70vh;
position: relative;
cursor: pointer;
-webkit-user-select: none;
}
#legend {
width: 200px;
}
</style>
</head>
<body>
<h1>Subzero size breakdown</h1>
<p>Click on a box to zoom in. Click on the outermost box to zoom out.</p>
<div id='map'></div>
<script src='webtreemap.js'></script>
<script>
var map = document.getElementById('map');
appendTreemap(map, kTree);
</script>
<div id='legend'>
<div class='webtreemap-symbol-bss'>bss</div>
<div class='webtreemap-symbol-bss webtreemap-aggregate'>bss aggregate</div>
<div class='webtreemap-symbol-data'>data</div>
<div class='webtreemap-symbol-data webtreemap-aggregate'>data aggregate</div>
<div class='webtreemap-symbol-read-only_data'>read-only data</div>
<div class='webtreemap-symbol-read-only_data webtreemap-aggregate'>read-only
data aggregate</div>
<div class='webtreemap-symbol-code'>code</div>
<div class='webtreemap-symbol-code webtreemap-aggregate'>code aggregate</div>
<div class='webtreemap-symbol-weak_symbol'>weak symbol</div>
<div class='webtreemap-symbol-weak_symbol webtreemap-aggregate'>weak symbol
aggregate</div>
</div>
</body>
<!DOCTYPE html>
<head>
<title>Subzero size breakdown</title>
<script src='../build/pnacl_public_x86_64_pnacl_sz_nexe.bloat.json'></script>
<link rel='stylesheet' href='webtreemap.css'>
<style>
body {
font-family: sans-serif;
font-size: 0.8em;
margin: 2ex 4ex;
}
h1 {
font-weight: normal;
}
#map {
height: 70vh;
position: relative;
cursor: pointer;
-webkit-user-select: none;
}
#legend {
width: 200px;
}
</style>
</head>
<body>
<h1>Subzero size breakdown</h1>
<p>Click on a box to zoom in. Click on the outermost box to zoom out.</p>
<div id='map'></div>
<script src='webtreemap.js'></script>
<script>
var map = document.getElementById('map');
appendTreemap(map, kTree);
</script>
<div id='legend'>
<div class='webtreemap-symbol-bss'>bss</div>
<div class='webtreemap-symbol-bss webtreemap-aggregate'>bss aggregate</div>
<div class='webtreemap-symbol-data'>data</div>
<div class='webtreemap-symbol-data webtreemap-aggregate'>data aggregate</div>
<div class='webtreemap-symbol-read-only_data'>read-only data</div>
<div class='webtreemap-symbol-read-only_data webtreemap-aggregate'>read-only
data aggregate</div>
<div class='webtreemap-symbol-code'>code</div>
<div class='webtreemap-symbol-code webtreemap-aggregate'>code aggregate</div>
<div class='webtreemap-symbol-weak_symbol'>weak symbol</div>
<div class='webtreemap-symbol-weak_symbol webtreemap-aggregate'>weak symbol
aggregate</div>
</div>
</body>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment