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):
buildbot_common.ErrorExit('Invalid toolchain(s): %s' % (
', '.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,
clobber=False, configs=None, first_toolchain=False):
......@@ -123,11 +143,12 @@ def UpdateProjects(pepperdir, project_tree, toolchains,
buildbot_common.RemoveDir(dirpath)
buildbot_common.MakeDir(dirpath)
targets = [desc['NAME'] for desc in projects]
deps = GetDeps(projects)
# Generate master make for this branch of projects
generate_make.GenerateMasterMakefile(pepperdir,
os.path.join(pepperdir, branch),
targets)
targets, deps)
if branch.startswith('examples') and not landing_page:
landing_page = LandingPage()
......@@ -156,7 +177,7 @@ def UpdateProjects(pepperdir, project_tree, toolchains,
branch_name = 'examples'
generate_make.GenerateMasterMakefile(pepperdir,
os.path.join(pepperdir, branch_name),
targets)
targets, {})
def BuildProjectsBranch(pepperdir, branch, deps, clean, config, args=None):
......
......@@ -353,7 +353,6 @@ def MakeNinjaRelPath(path):
TOOLCHAIN_LIBS = {
'bionic' : [
'libminidump_generator.a',
'libnacl.a',
'libnacl_dyncode.a',
'libnacl_exception.a',
'libnacl_list_mappings.a',
......
......@@ -276,7 +276,7 @@ def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None,
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.
Args:
......@@ -289,6 +289,7 @@ def GenerateMasterMakefile(pepperdir, out_path, targets):
rel_path = os.path.relpath(pepperdir, os.path.dirname(out_path))
template_dict = {
'projects': targets,
'deps' : deps,
'rel_sdk' : rel_path,
}
RunTemplateFileIfChanged(in_path, out_path, template_dict)
......
{
'TOOLS': ['newlib', 'glibc', 'pnacl', 'win', 'linux'],
'TOOLS': ['newlib', 'glibc', 'bionic', 'pnacl', 'win', 'linux'],
'TARGETS': [
{
'NAME' : 'audio',
......
{
'TOOLS': ['newlib', 'glibc', 'pnacl', 'win', 'linux'],
'TOOLS': ['newlib', 'glibc', 'pnacl', 'bionic', 'win', 'linux'],
'TARGETS': [
{
'NAME' : 'graphics_2d',
......
{
'TOOLS': ['newlib', 'glibc', 'pnacl'],
'TOOLS': ['newlib', 'glibc', 'pnacl', 'bionic'],
'TARGETS': [
{
'NAME' : 'nacl_io',
......
......@@ -18,6 +18,7 @@
],
# gmock-spec-builders.cc:248: error: enumeration value ‘FAIL’ not handled in switch
'CXXFLAGS': ['-Wno-switch-enum'],
'DEPS': ['gtest'],
}
],
'HEADERS': [
......
......@@ -12,6 +12,10 @@ PROJECTS := \
{{project}} \
[[]]
[[for dep,vals in deps.iteritems():]]
{{dep}}_DEPS:={{'_ALL_TARGET '.join(vals) + '_ALL_TARGET'}}
[[]]
HTTPD_PY := python {{rel_sdk}}/tools/httpd.py
ifeq ($(TOOLCHAIN),all)
......@@ -33,7 +37,7 @@ all:
define TARGET
ALL_TARGET_LIST+=$(1)_ALL_TARGET
.PHONY: $(1)_ALL_TARGET
$(1)_ALL_TARGET:
$(1)_ALL_TARGET: $$($(1)_DEPS)
+$(MAKE) -C $(1) $(TOOLCHAIN_ARG) all
CLEAN_TARGET_LIST+=$(1)_CLEAN_TARGET
......
......@@ -530,16 +530,17 @@ TEST_F(KernelWrapTest, truncate) {
EXPECT_EQ(0, truncate(kDummyConstChar, kDummyInt3));
}
#ifndef __BIONIC__
TEST_F(KernelWrapTest, lstat) {
struct stat buf;
EXPECT_CALL(mock, lstat(kDummyConstChar, &buf)).WillOnce(Return(-1));
EXPECT_EQ(-1, lstat(kDummyConstChar, &buf));
EXPECT_CALL(mock, lstat(kDummyConstChar, &buf)).WillOnce(Return(0));
EXPECT_EQ(0, lstat(kDummyConstChar, &buf));
struct stat in_statbuf;
MakeDummyStatbuf(&in_statbuf);
EXPECT_CALL(mock, lstat(StrEq(kDummyConstChar), _))
.WillOnce(DoAll(SetStat(&in_statbuf), Return(0)))
.WillOnce(Return(-1));
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) {
EXPECT_CALL(mock, unlink(kDummyConstChar)).WillOnce(Return(kDummyInt));
......
......@@ -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
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
#
......@@ -355,7 +367,7 @@ ifneq (,$(findstring arm,$(ARCHES)))
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)
$(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) $$@)
endif
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