Unlike the other toolchains, bionic supports both static and dynamic. This CL...

Unlike the other toolchains, bionic supports both static and dynamic.  This CL adds an environment variable which will allow SDK targets to be built with dynamic linking.  It also enables additional bionic targets such as nacl_io demo and test.

Since the current dynamic loader only supports searching DT_NEEDED namespaces for symbols, bionic forces us to declare dependencies explicitly which causes build order issues.

BUG=none
R=binji@chromium.org

Review URL: https://codereview.chromium.org/240493003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266900 0039d316-1c4b-4281-b951-d872f2087c98
parent aeafc385
...@@ -94,6 +94,26 @@ def ValidateToolchains(toolchains): ...@@ -94,6 +94,26 @@ def ValidateToolchains(toolchains):
buildbot_common.ErrorExit('Invalid toolchain(s): %s' % ( buildbot_common.ErrorExit('Invalid toolchain(s): %s' % (
', '.join(invalid_toolchains))) ', '.join(invalid_toolchains)))
def GetDeps(projects):
out = {}
# Build list of all project names
localtargets = [proj['NAME'] for proj in projects]
# For each project
for proj in projects:
deplist = []
# generate a list of dependencies
for targ in proj.get('TARGETS', []):
deplist.extend(targ.get('DEPS', []) + targ.get('LIBS', []))
# and add dependencies to targets built in this subtree
localdeps = [dep for dep in deplist if dep in localtargets]
if localdeps:
out[proj['NAME']] = localdeps
return out
def UpdateProjects(pepperdir, project_tree, toolchains, def UpdateProjects(pepperdir, project_tree, toolchains,
clobber=False, configs=None, first_toolchain=False): clobber=False, configs=None, first_toolchain=False):
...@@ -123,11 +143,12 @@ def UpdateProjects(pepperdir, project_tree, toolchains, ...@@ -123,11 +143,12 @@ def UpdateProjects(pepperdir, project_tree, toolchains,
buildbot_common.RemoveDir(dirpath) buildbot_common.RemoveDir(dirpath)
buildbot_common.MakeDir(dirpath) buildbot_common.MakeDir(dirpath)
targets = [desc['NAME'] for desc in projects] targets = [desc['NAME'] for desc in projects]
deps = GetDeps(projects)
# Generate master make for this branch of projects # Generate master make for this branch of projects
generate_make.GenerateMasterMakefile(pepperdir, generate_make.GenerateMasterMakefile(pepperdir,
os.path.join(pepperdir, branch), os.path.join(pepperdir, branch),
targets) targets, deps)
if branch.startswith('examples') and not landing_page: if branch.startswith('examples') and not landing_page:
landing_page = LandingPage() landing_page = LandingPage()
...@@ -156,7 +177,7 @@ def UpdateProjects(pepperdir, project_tree, toolchains, ...@@ -156,7 +177,7 @@ def UpdateProjects(pepperdir, project_tree, toolchains,
branch_name = 'examples' branch_name = 'examples'
generate_make.GenerateMasterMakefile(pepperdir, generate_make.GenerateMasterMakefile(pepperdir,
os.path.join(pepperdir, branch_name), os.path.join(pepperdir, branch_name),
targets) targets, {})
def BuildProjectsBranch(pepperdir, branch, deps, clean, config, args=None): def BuildProjectsBranch(pepperdir, branch, deps, clean, config, args=None):
......
...@@ -353,7 +353,6 @@ def MakeNinjaRelPath(path): ...@@ -353,7 +353,6 @@ def MakeNinjaRelPath(path):
TOOLCHAIN_LIBS = { TOOLCHAIN_LIBS = {
'bionic' : [ 'bionic' : [
'libminidump_generator.a', 'libminidump_generator.a',
'libnacl.a',
'libnacl_dyncode.a', 'libnacl_dyncode.a',
'libnacl_exception.a', 'libnacl_exception.a',
'libnacl_list_mappings.a', 'libnacl_list_mappings.a',
......
...@@ -276,7 +276,7 @@ def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None, ...@@ -276,7 +276,7 @@ def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None,
return (name, desc['DEST']) return (name, desc['DEST'])
def GenerateMasterMakefile(pepperdir, out_path, targets): def GenerateMasterMakefile(pepperdir, out_path, targets, deps):
"""Generate a Master Makefile that builds all examples. """Generate a Master Makefile that builds all examples.
Args: Args:
...@@ -289,6 +289,7 @@ def GenerateMasterMakefile(pepperdir, out_path, targets): ...@@ -289,6 +289,7 @@ def GenerateMasterMakefile(pepperdir, out_path, targets):
rel_path = os.path.relpath(pepperdir, os.path.dirname(out_path)) rel_path = os.path.relpath(pepperdir, os.path.dirname(out_path))
template_dict = { template_dict = {
'projects': targets, 'projects': targets,
'deps' : deps,
'rel_sdk' : rel_path, 'rel_sdk' : rel_path,
} }
RunTemplateFileIfChanged(in_path, out_path, template_dict) RunTemplateFileIfChanged(in_path, out_path, template_dict)
......
{ {
'TOOLS': ['newlib', 'glibc', 'pnacl', 'win', 'linux'], 'TOOLS': ['newlib', 'glibc', 'bionic', 'pnacl', 'win', 'linux'],
'TARGETS': [ 'TARGETS': [
{ {
'NAME' : 'audio', 'NAME' : 'audio',
......
{ {
'TOOLS': ['newlib', 'glibc', 'pnacl', 'win', 'linux'], 'TOOLS': ['newlib', 'glibc', 'pnacl', 'bionic', 'win', 'linux'],
'TARGETS': [ 'TARGETS': [
{ {
'NAME' : 'graphics_2d', 'NAME' : 'graphics_2d',
......
{ {
'TOOLS': ['newlib', 'glibc', 'pnacl'], 'TOOLS': ['newlib', 'glibc', 'pnacl', 'bionic'],
'TARGETS': [ 'TARGETS': [
{ {
'NAME' : 'nacl_io', 'NAME' : 'nacl_io',
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
], ],
# gmock-spec-builders.cc:248: error: enumeration value ‘FAIL’ not handled in switch # gmock-spec-builders.cc:248: error: enumeration value ‘FAIL’ not handled in switch
'CXXFLAGS': ['-Wno-switch-enum'], 'CXXFLAGS': ['-Wno-switch-enum'],
'DEPS': ['gtest'],
} }
], ],
'HEADERS': [ 'HEADERS': [
......
...@@ -12,6 +12,10 @@ PROJECTS := \ ...@@ -12,6 +12,10 @@ PROJECTS := \
{{project}} \ {{project}} \
[[]] [[]]
[[for dep,vals in deps.iteritems():]]
{{dep}}_DEPS:={{'_ALL_TARGET '.join(vals) + '_ALL_TARGET'}}
[[]]
HTTPD_PY := python {{rel_sdk}}/tools/httpd.py HTTPD_PY := python {{rel_sdk}}/tools/httpd.py
ifeq ($(TOOLCHAIN),all) ifeq ($(TOOLCHAIN),all)
...@@ -33,7 +37,7 @@ all: ...@@ -33,7 +37,7 @@ all:
define TARGET define TARGET
ALL_TARGET_LIST+=$(1)_ALL_TARGET ALL_TARGET_LIST+=$(1)_ALL_TARGET
.PHONY: $(1)_ALL_TARGET .PHONY: $(1)_ALL_TARGET
$(1)_ALL_TARGET: $(1)_ALL_TARGET: $$($(1)_DEPS)
+$(MAKE) -C $(1) $(TOOLCHAIN_ARG) all +$(MAKE) -C $(1) $(TOOLCHAIN_ARG) all
CLEAN_TARGET_LIST+=$(1)_CLEAN_TARGET CLEAN_TARGET_LIST+=$(1)_CLEAN_TARGET
......
...@@ -530,16 +530,17 @@ TEST_F(KernelWrapTest, truncate) { ...@@ -530,16 +530,17 @@ TEST_F(KernelWrapTest, truncate) {
EXPECT_EQ(0, truncate(kDummyConstChar, kDummyInt3)); EXPECT_EQ(0, truncate(kDummyConstChar, kDummyInt3));
} }
#ifndef __BIONIC__
TEST_F(KernelWrapTest, lstat) { TEST_F(KernelWrapTest, lstat) {
struct stat buf; struct stat in_statbuf;
EXPECT_CALL(mock, lstat(kDummyConstChar, &buf)).WillOnce(Return(-1)); MakeDummyStatbuf(&in_statbuf);
EXPECT_EQ(-1, lstat(kDummyConstChar, &buf)); EXPECT_CALL(mock, lstat(StrEq(kDummyConstChar), _))
.WillOnce(DoAll(SetStat(&in_statbuf), Return(0)))
EXPECT_CALL(mock, lstat(kDummyConstChar, &buf)).WillOnce(Return(0)); .WillOnce(Return(-1));
EXPECT_EQ(0, lstat(kDummyConstChar, &buf)); struct stat out_statbuf;
EXPECT_EQ(0, lstat(kDummyConstChar, &out_statbuf));
EXPECT_THAT(&in_statbuf, IsEqualToStatbuf(&out_statbuf));
EXPECT_EQ(-1, lstat(kDummyConstChar, &out_statbuf));
} }
#endif
TEST_F(KernelWrapTest, unlink) { TEST_F(KernelWrapTest, unlink) {
EXPECT_CALL(mock, unlink(kDummyConstChar)).WillOnce(Return(kDummyInt)); EXPECT_CALL(mock, unlink(kDummyConstChar)).WillOnce(Return(kDummyInt));
......
...@@ -73,6 +73,18 @@ X86_64_LDFLAGS ?= -Wl,-Map,$(X86_64_OUTDIR)/$(TARGET)_x86_64.map ...@@ -73,6 +73,18 @@ X86_64_LDFLAGS ?= -Wl,-Map,$(X86_64_OUTDIR)/$(TARGET)_x86_64.map
ARM_LDFLAGS ?= -Wl,-Map,$(ARM_OUTDIR)/$(TARGET)_arm.map ARM_LDFLAGS ?= -Wl,-Map,$(ARM_OUTDIR)/$(TARGET)_arm.map
endif endif
#
# Choose between static and dynamic linking for Bionic
# (Default to dynamic)
#
ifeq ($(TOOLCHAIN),bionic)
ifeq (,$(BIONIC_USE_DYNAMIC))
BIONIC_LINK:=-static
else
BIONIC_LINK:=-Wl,-Ttext-segment=0x100000
endif
endif
LDFLAGS_SHARED = -shared LDFLAGS_SHARED = -shared
# #
...@@ -355,7 +367,7 @@ ifneq (,$(findstring arm,$(ARCHES))) ...@@ -355,7 +367,7 @@ ifneq (,$(findstring arm,$(ARCHES)))
all: $(ARM_OUTDIR)/$(1)_arm.nexe all: $(ARM_OUTDIR)/$(1)_arm.nexe
$(ARM_OUTDIR)/$(1)_arm.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp) $(ARM_OUTDIR)/$(1)_arm.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
$(MKDIR) -p $$(dir $$@) $(MKDIR) -p $$(dir $$@)
$(call LOG,LINK,$$@,$(ARM_LINK) -static -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(ARM_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5)) $(call LOG,LINK,$$@,$(ARM_LINK) $(BIONIC_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(ARM_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@) $(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
endif endif
endef endef
......
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