summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authornoelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 16:52:35 +0000
committernoelallen@chromium.org <noelallen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-29 16:52:35 +0000
commit0673b415fe1a9f8bffb3de5cde04b282b7cd4fa2 (patch)
tree6afe885b284962422ef4aaf612c77df260fd3b82 /native_client_sdk
parentaeafc3850f1b0b3ba318c773e1164bde095968c9 (diff)
downloadchromium_src-0673b415fe1a9f8bffb3de5cde04b282b7cd4fa2.zip
chromium_src-0673b415fe1a9f8bffb3de5cde04b282b7cd4fa2.tar.gz
chromium_src-0673b415fe1a9f8bffb3de5cde04b282b7cd4fa2.tar.bz2
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
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-xnative_client_sdk/src/build_tools/build_projects.py25
-rwxr-xr-xnative_client_sdk/src/build_tools/build_sdk.py1
-rw-r--r--native_client_sdk/src/build_tools/generate_make.py3
-rw-r--r--native_client_sdk/src/examples/api/audio/example.dsc2
-rw-r--r--native_client_sdk/src/examples/api/graphics_2d/example.dsc2
-rw-r--r--native_client_sdk/src/examples/demo/nacl_io/example.dsc2
-rw-r--r--native_client_sdk/src/libraries/gmock/library.dsc1
-rw-r--r--native_client_sdk/src/resources/Makefile.index.template6
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc17
-rw-r--r--native_client_sdk/src/tools/nacl_gcc.mk14
10 files changed, 56 insertions, 17 deletions
diff --git a/native_client_sdk/src/build_tools/build_projects.py b/native_client_sdk/src/build_tools/build_projects.py
index dd8ec1c..ab3752c 100755
--- a/native_client_sdk/src/build_tools/build_projects.py
+++ b/native_client_sdk/src/build_tools/build_projects.py
@@ -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):
diff --git a/native_client_sdk/src/build_tools/build_sdk.py b/native_client_sdk/src/build_tools/build_sdk.py
index e90a142..fdebfed 100755
--- a/native_client_sdk/src/build_tools/build_sdk.py
+++ b/native_client_sdk/src/build_tools/build_sdk.py
@@ -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',
diff --git a/native_client_sdk/src/build_tools/generate_make.py b/native_client_sdk/src/build_tools/generate_make.py
index 4188e7a..45eb933 100644
--- a/native_client_sdk/src/build_tools/generate_make.py
+++ b/native_client_sdk/src/build_tools/generate_make.py
@@ -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)
diff --git a/native_client_sdk/src/examples/api/audio/example.dsc b/native_client_sdk/src/examples/api/audio/example.dsc
index 4d4e307..04d5cf9 100644
--- a/native_client_sdk/src/examples/api/audio/example.dsc
+++ b/native_client_sdk/src/examples/api/audio/example.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win', 'linux'],
+ 'TOOLS': ['newlib', 'glibc', 'bionic', 'pnacl', 'win', 'linux'],
'TARGETS': [
{
'NAME' : 'audio',
diff --git a/native_client_sdk/src/examples/api/graphics_2d/example.dsc b/native_client_sdk/src/examples/api/graphics_2d/example.dsc
index a9b31c77..9f5e5bf 100644
--- a/native_client_sdk/src/examples/api/graphics_2d/example.dsc
+++ b/native_client_sdk/src/examples/api/graphics_2d/example.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win', 'linux'],
+ 'TOOLS': ['newlib', 'glibc', 'pnacl', 'bionic', 'win', 'linux'],
'TARGETS': [
{
'NAME' : 'graphics_2d',
diff --git a/native_client_sdk/src/examples/demo/nacl_io/example.dsc b/native_client_sdk/src/examples/demo/nacl_io/example.dsc
index 1c85cc2..0f284fc 100644
--- a/native_client_sdk/src/examples/demo/nacl_io/example.dsc
+++ b/native_client_sdk/src/examples/demo/nacl_io/example.dsc
@@ -1,5 +1,5 @@
{
- 'TOOLS': ['newlib', 'glibc', 'pnacl'],
+ 'TOOLS': ['newlib', 'glibc', 'pnacl', 'bionic'],
'TARGETS': [
{
'NAME' : 'nacl_io',
diff --git a/native_client_sdk/src/libraries/gmock/library.dsc b/native_client_sdk/src/libraries/gmock/library.dsc
index ff42a87..074d131 100644
--- a/native_client_sdk/src/libraries/gmock/library.dsc
+++ b/native_client_sdk/src/libraries/gmock/library.dsc
@@ -18,6 +18,7 @@
],
# gmock-spec-builders.cc:248: error: enumeration value ‘FAIL’ not handled in switch
'CXXFLAGS': ['-Wno-switch-enum'],
+ 'DEPS': ['gtest'],
}
],
'HEADERS': [
diff --git a/native_client_sdk/src/resources/Makefile.index.template b/native_client_sdk/src/resources/Makefile.index.template
index 10a2e31..2881fdf 100644
--- a/native_client_sdk/src/resources/Makefile.index.template
+++ b/native_client_sdk/src/resources/Makefile.index.template
@@ -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
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
index c043445..bbfa600 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc
@@ -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));
diff --git a/native_client_sdk/src/tools/nacl_gcc.mk b/native_client_sdk/src/tools/nacl_gcc.mk
index 832efeb..9f7c478 100644
--- a/native_client_sdk/src/tools/nacl_gcc.mk
+++ b/native_client_sdk/src/tools/nacl_gcc.mk
@@ -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