summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorsbc <sbc@chromium.org>2015-10-23 18:20:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-24 01:22:01 +0000
commit95ffabc8eb818b26009f0eff87db5be3ec1487a0 (patch)
tree2c5c7ff7def6ea9d3acf728d260364e8b5bc71cd /native_client_sdk
parent939f64cf8b666cb2c1dbb777193b4ee4f1e52236 (diff)
downloadchromium_src-95ffabc8eb818b26009f0eff87db5be3ec1487a0.zip
chromium_src-95ffabc8eb818b26009f0eff87db5be3ec1487a0.tar.gz
chromium_src-95ffabc8eb818b26009f0eff87db5be3ec1487a0.tar.bz2
[NaCl SDK] Allow ppapi_simple apps to use main entry point.
This change makes ppapi_simple into a linker script since we need to force the __nacl_main symbol to be included in the link line (its weak referenced by _start as a replacement for main). CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_nacl_sdk;tryserver.chromium.mac:mac_nacl_sdk;tryserver.chromium.win:win_nacl_sdk BUG=246246 Review URL: https://codereview.chromium.org/18435011 Cr-Commit-Position: refs/heads/master@{#355947}
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-xnative_client_sdk/src/build_tools/parse_dsc.py4
-rw-r--r--native_client_sdk/src/build_tools/sdk_files.list49
-rw-r--r--native_client_sdk/src/doc/devguide/devcycle/building.rst7
-rw-r--r--native_client_sdk/src/examples/demo/earth/earth.cc10
-rw-r--r--native_client_sdk/src/examples/demo/earth_simd/earth.cc10
-rw-r--r--native_client_sdk/src/examples/demo/flock/flock.cc9
-rw-r--r--native_client_sdk/src/examples/demo/life/life.c10
-rw-r--r--native_client_sdk/src/examples/demo/life_simd/life.cc7
-rw-r--r--native_client_sdk/src/examples/demo/pi_generator/pi_generator.cc9
-rw-r--r--native_client_sdk/src/examples/demo/voronoi/voronoi.cc10
-rw-r--r--native_client_sdk/src/examples/tutorial/testing/testing.cc6
-rw-r--r--native_client_sdk/src/examples/tutorial/using_ppapi_simple/hello_world.c13
-rw-r--r--native_client_sdk/src/gonacl_appengine/src/life/life.c12
-rw-r--r--native_client_sdk/src/gonacl_appengine/src/voronoi/voronoi.cc10
-rw-r--r--native_client_sdk/src/libraries/ppapi/ppapi_externs.c6
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/library.dsc9
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.a.linkerscript10
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.so.linkerscript13
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/ps.h6
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/ps_entrypoints_c.c5
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/ps_main.c20
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/ps_main.h4
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple/ps_main_default.c10
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc9
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.a.linkerscript10
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.so.linkerscript13
-rw-r--r--native_client_sdk/src/libraries/ppapi_simple_cpp/ps_entrypoints_cpp.cc11
-rw-r--r--native_client_sdk/src/libraries/sdk_util/macros.h18
-rw-r--r--native_client_sdk/src/resources/Makefile.example.template1
-rw-r--r--native_client_sdk/src/resources/Makefile.library.template57
-rw-r--r--native_client_sdk/src/tests/nacl_io_socket_test/example.dsc4
-rw-r--r--native_client_sdk/src/tests/nacl_io_socket_test/main.cc7
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/example.dsc4
-rw-r--r--native_client_sdk/src/tests/nacl_io_test/main.cc6
-rw-r--r--native_client_sdk/src/tests/sdk_util_test/example.dsc4
-rw-r--r--native_client_sdk/src/tests/sdk_util_test/main.cc6
-rw-r--r--native_client_sdk/src/tools/host_gcc.mk33
-rwxr-xr-xnative_client_sdk/src/tools/mac_ld_wrapper.py35
-rw-r--r--native_client_sdk/src/tools/nacl_gcc.mk64
-rw-r--r--native_client_sdk/src/tools/nacl_llvm.mk18
40 files changed, 359 insertions, 190 deletions
diff --git a/native_client_sdk/src/build_tools/parse_dsc.py b/native_client_sdk/src/build_tools/parse_dsc.py
index 2fda59b..6511ada 100755
--- a/native_client_sdk/src/build_tools/parse_dsc.py
+++ b/native_client_sdk/src/build_tools/parse_dsc.py
@@ -38,7 +38,9 @@ DSC_FORMAT = {
# lib = library target
# so = shared object target, automatically added to NMF
# so-standalone = shared object target, not put into NMF
- 'TYPE': (str, ['main', 'lib', 'static-lib', 'so', 'so-standalone'],
+ 'TYPE': (str,
+ ['main', 'lib', 'static-lib', 'so', 'so-standalone',
+ 'linker-script'],
True),
'SOURCES': (list, '', True),
'CFLAGS': (list, '', False),
diff --git a/native_client_sdk/src/build_tools/sdk_files.list b/native_client_sdk/src/build_tools/sdk_files.list
index a502a2f2..a7676e5 100644
--- a/native_client_sdk/src/build_tools/sdk_files.list
+++ b/native_client_sdk/src/build_tools/sdk_files.list
@@ -107,7 +107,11 @@ include/win/sys/poll.h
[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_cpp_private.a
[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_gles2.a
[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_simple.a
+[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_simple.so
[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_simple_cpp.a
+[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_simple_cpp.so
+[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_simple_cpp_real.a
+[linux,mac]lib/${PLATFORM}_host/Debug/libppapi_simple_real.a
[linux,mac]lib/${PLATFORM}_host/Debug/libsdk_util.a
[linux,mac]lib/${PLATFORM}_host/Release/libgmock.a
[linux,mac]lib/${PLATFORM}_host/Release/libgtest.a
@@ -118,7 +122,11 @@ include/win/sys/poll.h
[linux,mac]lib/${PLATFORM}_host/Release/libppapi_cpp_private.a
[linux,mac]lib/${PLATFORM}_host/Release/libppapi_gles2.a
[linux,mac]lib/${PLATFORM}_host/Release/libppapi_simple.a
+[linux,mac]lib/${PLATFORM}_host/Release/libppapi_simple.so
[linux,mac]lib/${PLATFORM}_host/Release/libppapi_simple_cpp.a
+[linux,mac]lib/${PLATFORM}_host/Release/libppapi_simple_cpp.so
+[linux,mac]lib/${PLATFORM}_host/Release/libppapi_simple_cpp_real.a
+[linux,mac]lib/${PLATFORM}_host/Release/libppapi_simple_real.a
[linux,mac]lib/${PLATFORM}_host/Release/libsdk_util.a
[win]lib/${PLATFORM}_x86_32_host/Debug/gmock.lib
[win]lib/${PLATFORM}_x86_32_host/Debug/gtest.lib
@@ -148,6 +156,8 @@ lib/clang-newlib_arm/Debug/libppapi_cpp_private.a
lib/clang-newlib_arm/Debug/libppapi_gles2.a
lib/clang-newlib_arm/Debug/libppapi_simple.a
lib/clang-newlib_arm/Debug/libppapi_simple_cpp.a
+lib/clang-newlib_arm/Debug/libppapi_simple_cpp_real.a
+lib/clang-newlib_arm/Debug/libppapi_simple_real.a
lib/clang-newlib_arm/Debug/libsdk_util.a
lib/clang-newlib_arm/Release/liberror_handling.a
lib/clang-newlib_arm/Release/libgmock.a
@@ -159,6 +169,8 @@ lib/clang-newlib_arm/Release/libppapi_cpp_private.a
lib/clang-newlib_arm/Release/libppapi_gles2.a
lib/clang-newlib_arm/Release/libppapi_simple.a
lib/clang-newlib_arm/Release/libppapi_simple_cpp.a
+lib/clang-newlib_arm/Release/libppapi_simple_cpp_real.a
+lib/clang-newlib_arm/Release/libppapi_simple_real.a
lib/clang-newlib_arm/Release/libsdk_util.a
lib/clang-newlib_x86_32/Debug/liberror_handling.a
lib/clang-newlib_x86_32/Debug/libgmock.a
@@ -170,6 +182,8 @@ lib/clang-newlib_x86_32/Debug/libppapi_cpp_private.a
lib/clang-newlib_x86_32/Debug/libppapi_gles2.a
lib/clang-newlib_x86_32/Debug/libppapi_simple.a
lib/clang-newlib_x86_32/Debug/libppapi_simple_cpp.a
+lib/clang-newlib_x86_32/Debug/libppapi_simple_cpp_real.a
+lib/clang-newlib_x86_32/Debug/libppapi_simple_real.a
lib/clang-newlib_x86_32/Debug/libsdk_util.a
lib/clang-newlib_x86_32/Release/liberror_handling.a
lib/clang-newlib_x86_32/Release/libgmock.a
@@ -181,6 +195,8 @@ lib/clang-newlib_x86_32/Release/libppapi_cpp_private.a
lib/clang-newlib_x86_32/Release/libppapi_gles2.a
lib/clang-newlib_x86_32/Release/libppapi_simple.a
lib/clang-newlib_x86_32/Release/libppapi_simple_cpp.a
+lib/clang-newlib_x86_32/Release/libppapi_simple_cpp_real.a
+lib/clang-newlib_x86_32/Release/libppapi_simple_real.a
lib/clang-newlib_x86_32/Release/libsdk_util.a
lib/clang-newlib_x86_64/Debug/liberror_handling.a
lib/clang-newlib_x86_64/Debug/libgmock.a
@@ -192,6 +208,8 @@ lib/clang-newlib_x86_64/Debug/libppapi_cpp_private.a
lib/clang-newlib_x86_64/Debug/libppapi_gles2.a
lib/clang-newlib_x86_64/Debug/libppapi_simple.a
lib/clang-newlib_x86_64/Debug/libppapi_simple_cpp.a
+lib/clang-newlib_x86_64/Debug/libppapi_simple_cpp_real.a
+lib/clang-newlib_x86_64/Debug/libppapi_simple_real.a
lib/clang-newlib_x86_64/Debug/libsdk_util.a
lib/clang-newlib_x86_64/Release/liberror_handling.a
lib/clang-newlib_x86_64/Release/libgmock.a
@@ -203,6 +221,8 @@ lib/clang-newlib_x86_64/Release/libppapi_cpp_private.a
lib/clang-newlib_x86_64/Release/libppapi_gles2.a
lib/clang-newlib_x86_64/Release/libppapi_simple.a
lib/clang-newlib_x86_64/Release/libppapi_simple_cpp.a
+lib/clang-newlib_x86_64/Release/libppapi_simple_cpp_real.a
+lib/clang-newlib_x86_64/Release/libppapi_simple_real.a
lib/clang-newlib_x86_64/Release/libsdk_util.a
lib/glibc_arm/Debug/libgmock.a
lib/glibc_arm/Debug/libgmock.so
@@ -222,6 +242,10 @@ lib/glibc_arm/Debug/libppapi_simple.a
lib/glibc_arm/Debug/libppapi_simple.so
lib/glibc_arm/Debug/libppapi_simple_cpp.a
lib/glibc_arm/Debug/libppapi_simple_cpp.so
+lib/glibc_arm/Debug/libppapi_simple_cpp_real.a
+lib/glibc_arm/Debug/libppapi_simple_cpp_real.so
+lib/glibc_arm/Debug/libppapi_simple_real.a
+lib/glibc_arm/Debug/libppapi_simple_real.so
lib/glibc_arm/Debug/libsdk_util.a
lib/glibc_arm/Debug/libsdk_util.so
lib/glibc_arm/Release/libgmock.a
@@ -242,6 +266,10 @@ lib/glibc_arm/Release/libppapi_simple.a
lib/glibc_arm/Release/libppapi_simple.so
lib/glibc_arm/Release/libppapi_simple_cpp.a
lib/glibc_arm/Release/libppapi_simple_cpp.so
+lib/glibc_arm/Release/libppapi_simple_cpp_real.a
+lib/glibc_arm/Release/libppapi_simple_cpp_real.so
+lib/glibc_arm/Release/libppapi_simple_real.a
+lib/glibc_arm/Release/libppapi_simple_real.so
lib/glibc_arm/Release/libsdk_util.a
lib/glibc_arm/Release/libsdk_util.so
lib/glibc_x86_32/Debug/libgmock.a
@@ -262,6 +290,10 @@ lib/glibc_x86_32/Debug/libppapi_simple.a
lib/glibc_x86_32/Debug/libppapi_simple.so
lib/glibc_x86_32/Debug/libppapi_simple_cpp.a
lib/glibc_x86_32/Debug/libppapi_simple_cpp.so
+lib/glibc_x86_32/Debug/libppapi_simple_cpp_real.a
+lib/glibc_x86_32/Debug/libppapi_simple_cpp_real.so
+lib/glibc_x86_32/Debug/libppapi_simple_real.a
+lib/glibc_x86_32/Debug/libppapi_simple_real.so
lib/glibc_x86_32/Debug/libsdk_util.a
lib/glibc_x86_32/Debug/libsdk_util.so
lib/glibc_x86_32/Release/libgmock.a
@@ -282,6 +314,10 @@ lib/glibc_x86_32/Release/libppapi_simple.a
lib/glibc_x86_32/Release/libppapi_simple.so
lib/glibc_x86_32/Release/libppapi_simple_cpp.a
lib/glibc_x86_32/Release/libppapi_simple_cpp.so
+lib/glibc_x86_32/Release/libppapi_simple_cpp_real.a
+lib/glibc_x86_32/Release/libppapi_simple_cpp_real.so
+lib/glibc_x86_32/Release/libppapi_simple_real.a
+lib/glibc_x86_32/Release/libppapi_simple_real.so
lib/glibc_x86_32/Release/libsdk_util.a
lib/glibc_x86_32/Release/libsdk_util.so
lib/glibc_x86_64/Debug/libgmock.a
@@ -302,6 +338,10 @@ lib/glibc_x86_64/Debug/libppapi_simple.a
lib/glibc_x86_64/Debug/libppapi_simple.so
lib/glibc_x86_64/Debug/libppapi_simple_cpp.a
lib/glibc_x86_64/Debug/libppapi_simple_cpp.so
+lib/glibc_x86_64/Debug/libppapi_simple_cpp_real.a
+lib/glibc_x86_64/Debug/libppapi_simple_cpp_real.so
+lib/glibc_x86_64/Debug/libppapi_simple_real.a
+lib/glibc_x86_64/Debug/libppapi_simple_real.so
lib/glibc_x86_64/Debug/libsdk_util.a
lib/glibc_x86_64/Debug/libsdk_util.so
lib/glibc_x86_64/Release/libgmock.a
@@ -322,6 +362,10 @@ lib/glibc_x86_64/Release/libppapi_simple.a
lib/glibc_x86_64/Release/libppapi_simple.so
lib/glibc_x86_64/Release/libppapi_simple_cpp.a
lib/glibc_x86_64/Release/libppapi_simple_cpp.so
+lib/glibc_x86_64/Release/libppapi_simple_cpp_real.a
+lib/glibc_x86_64/Release/libppapi_simple_cpp_real.so
+lib/glibc_x86_64/Release/libppapi_simple_real.a
+lib/glibc_x86_64/Release/libppapi_simple_real.so
lib/glibc_x86_64/Release/libsdk_util.a
lib/glibc_x86_64/Release/libsdk_util.so
lib/pnacl/Debug/libgmock.a
@@ -333,6 +377,8 @@ lib/pnacl/Debug/libppapi_cpp_private.a
lib/pnacl/Debug/libppapi_gles2.a
lib/pnacl/Debug/libppapi_simple.a
lib/pnacl/Debug/libppapi_simple_cpp.a
+lib/pnacl/Debug/libppapi_simple_cpp_real.a
+lib/pnacl/Debug/libppapi_simple_real.a
lib/pnacl/Debug/libsdk_util.a
lib/pnacl/Release/libgmock.a
lib/pnacl/Release/libgtest.a
@@ -343,6 +389,8 @@ lib/pnacl/Release/libppapi_cpp_private.a
lib/pnacl/Release/libppapi_gles2.a
lib/pnacl/Release/libppapi_simple.a
lib/pnacl/Release/libppapi_simple_cpp.a
+lib/pnacl/Release/libppapi_simple_cpp_real.a
+lib/pnacl/Release/libppapi_simple_real.a
lib/pnacl/Release/libsdk_util.a
LICENSE
NOTICE
@@ -476,6 +524,7 @@ tools/irt_core_x86_64.nexe
tools/lib/elf.py
tools/lib/get_shared_deps.py
tools/lib/quote.py
+tools/mac_ld_wrapper.py
[win]tools/make.exe
[linux,mac]tools/minidump_dump
[linux,mac]tools/minidump_stackwalk
diff --git a/native_client_sdk/src/doc/devguide/devcycle/building.rst b/native_client_sdk/src/doc/devguide/devcycle/building.rst
index 1c71855..ea18759 100644
--- a/native_client_sdk/src/doc/devguide/devcycle/building.rst
+++ b/native_client_sdk/src/doc/devguide/devcycle/building.rst
@@ -621,10 +621,9 @@ libnacl_io.a
libppapi_simple.a
Provides a familiar C programming environment by letting a module have a
- simple entry point that is registered by ``PPAPI_SIMPLE_REGISTER_MAIN``.
- The entry point is similar to the standard C ``main()`` function, complete
- with ``argc`` and ``argv[]`` parameters. For details see
- ``include/ppapi_simple/ps.h``. For an example of
+ simple ``main()`` entry point. The entry point is similar to the standard C
+ ``main()`` function, complete with ``argc`` and ``argv[]`` parameters. For
+ details see ``include/ppapi_simple/ps.h``. For an example of
how to use ppapi_simple, ``see examples/tutorial/using_ppapi_simple``.
diff --git a/native_client_sdk/src/examples/demo/earth/earth.cc b/native_client_sdk/src/examples/demo/earth/earth.cc
index 1f75007..b6fabfe 100644
--- a/native_client_sdk/src/examples/demo/earth/earth.cc
+++ b/native_client_sdk/src/examples/demo/earth/earth.cc
@@ -24,7 +24,6 @@
#include "ppapi_simple/ps_context_2d.h"
#include "ppapi_simple/ps_event.h"
#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_main.h"
#include "sdk_util/macros.h"
#include "sdk_util/thread_pool.h"
@@ -799,9 +798,8 @@ void Planet::Update() {
}
-// Starting point for the module. We do not use main since it would
-// collide with main in libppapi_cpp.
-int example_main(int argc, char* argv[]) {
+// Starting point for the module.
+int main(int argc, char* argv[]) {
Planet earth;
while (true) {
PSEvent* ps_event;
@@ -816,7 +814,3 @@ int example_main(int argc, char* argv[]) {
return 0;
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/demo/earth_simd/earth.cc b/native_client_sdk/src/examples/demo/earth_simd/earth.cc
index 2cf29e3..3dda1ed6 100644
--- a/native_client_sdk/src/examples/demo/earth_simd/earth.cc
+++ b/native_client_sdk/src/examples/demo/earth_simd/earth.cc
@@ -24,7 +24,6 @@
#include "ppapi_simple/ps_context_2d.h"
#include "ppapi_simple/ps_event.h"
#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_main.h"
#include "sdk_util/macros.h"
#include "sdk_util/thread_pool.h"
@@ -839,9 +838,8 @@ void Planet::Update() {
}
-// Starting point for the module. We do not use main since it would
-// collide with main in libppapi_cpp.
-int example_main(int argc, char* argv[]) {
+// Starting point for the module.
+int main(int argc, char* argv[]) {
Planet earth;
while (true) {
PSEvent* ps_event;
@@ -856,7 +854,3 @@ int example_main(int argc, char* argv[]) {
return 0;
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/demo/flock/flock.cc b/native_client_sdk/src/examples/demo/flock/flock.cc
index 9e1a639..d8e8f62 100644
--- a/native_client_sdk/src/examples/demo/flock/flock.cc
+++ b/native_client_sdk/src/examples/demo/flock/flock.cc
@@ -16,7 +16,6 @@
#include "ppapi/c/pp_size.h"
#include "ppapi_simple/ps_context_2d.h"
-#include "ppapi_simple/ps_main.h"
#include "goose.h"
#include "sprite.h"
@@ -96,7 +95,7 @@ void Render(PSContext2D_t* ctx) {
* Starting point for the module. We do not use main since it would
* collide with main in libppapi_cpp.
*/
-int example_main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
ImageFormat fmt;
uint32_t* buffer;
size_t len;
@@ -141,9 +140,3 @@ int example_main(int argc, char *argv[]) {
return 0;
}
-
-/*
- * Register the function to call once the Instance Object is initialized.
- * see: pappi_simple/ps_main.h
- */
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/demo/life/life.c b/native_client_sdk/src/examples/demo/life/life.c
index 6bd28b5..511c488 100644
--- a/native_client_sdk/src/examples/demo/life/life.c
+++ b/native_client_sdk/src/examples/demo/life/life.c
@@ -19,7 +19,7 @@
#include "ppapi/c/ppb_view.h"
#include "ppapi_simple/ps_event.h"
-#include "ppapi_simple/ps_main.h"
+#include "ppapi_simple/ps.h"
PPB_Core* g_pCore;
PPB_Fullscreen* g_pFullscreen;
@@ -284,7 +284,7 @@ void Render() {
* Starting point for the module. We do not use main since it would
* collide with main in libppapi_cpp.
*/
-int example_main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
fprintf(stdout,"Started main.\n");
g_pCore = (PPB_Core*)PSGetInterface(PPB_CORE_INTERFACE);
g_pFullscreen = (PPB_Fullscreen*)PSGetInterface(PPB_FULLSCREEN_INTERFACE);
@@ -318,9 +318,3 @@ int example_main(int argc, char *argv[]) {
}
return 0;
}
-
-/*
- * Register the function to call once the Instance Object is initialized.
- * see: pappi_simple/ps_main.h
- */
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/demo/life_simd/life.cc b/native_client_sdk/src/examples/demo/life_simd/life.cc
index b99f2bc..17b7cc2 100644
--- a/native_client_sdk/src/examples/demo/life_simd/life.cc
+++ b/native_client_sdk/src/examples/demo/life_simd/life.cc
@@ -25,7 +25,6 @@
#include "ppapi_simple/ps_event.h"
#include "ppapi_simple/ps_instance.h"
#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_main.h"
#include "sdk_util/macros.h"
#include "sdk_util/thread_pool.h"
@@ -505,7 +504,7 @@ void Life::Update() {
// Starting point for the module. We do not use main since it would
// collide with main in libppapi_cpp.
-int example_main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
Life life;
while (true) {
PSEvent* ps_event;
@@ -519,7 +518,3 @@ int example_main(int argc, char* argv[]) {
}
return 0;
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/demo/pi_generator/pi_generator.cc b/native_client_sdk/src/examples/demo/pi_generator/pi_generator.cc
index 59ae061..db54b1b 100644
--- a/native_client_sdk/src/examples/demo/pi_generator/pi_generator.cc
+++ b/native_client_sdk/src/examples/demo/pi_generator/pi_generator.cc
@@ -9,7 +9,6 @@
#include "ppapi_simple/ps_context_2d.h"
#include "ppapi_simple/ps_event.h"
#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_main.h"
#ifdef WIN32
#undef PostMessage
@@ -69,7 +68,7 @@ bool Render(PSContext2D_t* ctx) {
* Starting point for the module. We do not use main since it would
* collide with main in libppapi_cpp.
*/
-int example_main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
unsigned int seed = 1;
srand(seed);
@@ -97,9 +96,3 @@ int example_main(int argc, char* argv[]) {
return 0;
}
-
-/*
- * Register the function to call once the Instance Object is initialized.
- * see: pappi_simple/ps_main.h
- */
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/demo/voronoi/voronoi.cc b/native_client_sdk/src/examples/demo/voronoi/voronoi.cc
index 99cf566..90e1a71 100644
--- a/native_client_sdk/src/examples/demo/voronoi/voronoi.cc
+++ b/native_client_sdk/src/examples/demo/voronoi/voronoi.cc
@@ -24,7 +24,6 @@
#include "ppapi_simple/ps_context_2d.h"
#include "ppapi_simple/ps_event.h"
#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_main.h"
#include "sdk_util/thread_pool.h"
using namespace sdk_util; // For sdk_util::ThreadPool
@@ -520,9 +519,8 @@ void Voronoi::Update() {
PSContext2DSwapBuffer(ps_context_);
}
-// Starting point for the module. We do not use main since it would
-// collide with main in libppapi_cpp.
-int example_main(int argc, char* argv[]) {
+// Starting point for the module.
+int main(int argc, char* argv[]) {
Voronoi voronoi;
while (true) {
PSEvent* ps_event;
@@ -537,7 +535,3 @@ int example_main(int argc, char* argv[]) {
return 0;
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/tutorial/testing/testing.cc b/native_client_sdk/src/examples/tutorial/testing/testing.cc
index b44b5a1..fba899f 100644
--- a/native_client_sdk/src/examples/tutorial/testing/testing.cc
+++ b/native_client_sdk/src/examples/tutorial/testing/testing.cc
@@ -48,7 +48,7 @@ class GTestEventListener : public ::testing::EmptyTestEventListener {
}
};
-int example_main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
setenv("TERM", "xterm-256color", 0);
::testing::InitGoogleTest(&argc, argv);
if (PSGetInstanceId() != 0) {
@@ -57,7 +57,3 @@ int example_main(int argc, char* argv[]) {
}
return RUN_ALL_TESTS();
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/examples/tutorial/using_ppapi_simple/hello_world.c b/native_client_sdk/src/examples/tutorial/using_ppapi_simple/hello_world.c
index 31e88fa5..01792ee 100644
--- a/native_client_sdk/src/examples/tutorial/using_ppapi_simple/hello_world.c
+++ b/native_client_sdk/src/examples/tutorial/using_ppapi_simple/hello_world.c
@@ -6,9 +6,7 @@
#include <stdio.h>
#include <string.h>
-#include "ppapi_simple/ps_main.h"
-
-int example_main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
/* Use ppb_messaging to send "Hello World" to JavaScript. */
printf("Hello World STDOUT.\n");
@@ -16,12 +14,3 @@ int example_main(int argc, char* argv[]) {
fprintf(stderr, "Hello World STDERR.\n");
return 0;
}
-
-/*
- * Register the function to call once the Instance Object is initialized.
- * see: pappi_simple/ps_main.h
- *
- * This is not needed when building the sel_ldr version of this example
- * which does not link against ppapi_simple.
- */
-PPAPI_SIMPLE_REGISTER_MAIN(example_main)
diff --git a/native_client_sdk/src/gonacl_appengine/src/life/life.c b/native_client_sdk/src/gonacl_appengine/src/life/life.c
index 8fb4d44..3b3d2e9 100644
--- a/native_client_sdk/src/gonacl_appengine/src/life/life.c
+++ b/native_client_sdk/src/gonacl_appengine/src/life/life.c
@@ -22,7 +22,6 @@
#include "ppapi/c/ppb_view.h"
#include "ppapi_simple/ps_event.h"
-#include "ppapi_simple/ps_main.h"
PPB_Core* g_pCore;
PPB_Graphics2D* g_pGraphics2D;
@@ -279,10 +278,9 @@ void Render() {
}
/*
- * Starting point for the module. We do not use main since it would
- * collide with main in libppapi_cpp.
+ * Starting point for the module.
*/
-int example_main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
fprintf(stdout,"Started main.\n");
FpsInit(&g_fps_state);
@@ -321,9 +319,3 @@ int example_main(int argc, char *argv[]) {
}
return 0;
}
-
-/*
- * Register the function to call once the Instance Object is initialized.
- * see: pappi_simple/ps_main.h
- */
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/gonacl_appengine/src/voronoi/voronoi.cc b/native_client_sdk/src/gonacl_appengine/src/voronoi/voronoi.cc
index 7f00967..591966e 100644
--- a/native_client_sdk/src/gonacl_appengine/src/voronoi/voronoi.cc
+++ b/native_client_sdk/src/gonacl_appengine/src/voronoi/voronoi.cc
@@ -24,7 +24,6 @@
#include "ppapi_simple/ps_context_2d.h"
#include "ppapi_simple/ps_event.h"
#include "ppapi_simple/ps_interface.h"
-#include "ppapi_simple/ps_main.h"
#include "sdk_util/thread_pool.h"
using namespace sdk_util; // For sdk_util::ThreadPool
@@ -481,9 +480,8 @@ void Voronoi::Update() {
PostUpdateMessage("fps", fps);
}
-// Starting point for the module. We do not use main since it would
-// collide with main in libppapi_cpp.
-int example_main(int argc, char* argv[]) {
+// Starting point for the module.
+int main(int argc, char* argv[]) {
Voronoi voronoi;
while (true) {
PSEvent* ps_event;
@@ -498,7 +496,3 @@ int example_main(int argc, char* argv[]) {
return 0;
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/libraries/ppapi/ppapi_externs.c b/native_client_sdk/src/libraries/ppapi/ppapi_externs.c
index b082244..aa9f4da 100644
--- a/native_client_sdk/src/libraries/ppapi/ppapi_externs.c
+++ b/native_client_sdk/src/libraries/ppapi/ppapi_externs.c
@@ -1,4 +1,8 @@
+/* Copyright 2015 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
#include "ppapi/c/ppp.h"
/* Add a global symbol to force the linker to generate a LIB. */
-const char *g_BogusSymbol;
+void _lib_ppapi_dummy_symbol() {}
diff --git a/native_client_sdk/src/libraries/ppapi_simple/library.dsc b/native_client_sdk/src/libraries/ppapi_simple/library.dsc
index 56332e5..8729ebe 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi_simple/library.dsc
@@ -3,6 +3,14 @@
'TARGETS': [
{
'NAME' : 'ppapi_simple',
+ 'TYPE' : 'linker-script',
+ 'SOURCES' : [
+ "ppapi_simple.a.linkerscript",
+ "ppapi_simple.so.linkerscript",
+ ],
+ },
+ {
+ 'NAME' : 'ppapi_simple_real',
'TYPE' : 'lib',
'LIBS': ['nacl_io'],
'DEPS': ['nacl_io'],
@@ -13,6 +21,7 @@
"ps_instance.c",
"ps_interface.c",
"ps_main.c",
+ "ps_main_default.c",
"ps_entrypoints_c.c"
],
},
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.a.linkerscript b/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.a.linkerscript
new file mode 100644
index 0000000..da56609
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.a.linkerscript
@@ -0,0 +1,10 @@
+/*
+ * Copyright 2015 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* When using pnacl-ld, -l<library name> doesn't work. */
+
+INPUT ( libppapi_simple_real.a )
+EXTERN ( PSUserMainGet __nacl_main PPP_InitializeModule )
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.so.linkerscript b/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.so.linkerscript
new file mode 100644
index 0000000..9b29253
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_simple/ppapi_simple.so.linkerscript
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2015 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * glibc requires -l<library name>. Using lib<library name>.{a,so} will end up
+ * adding the absolute path to the NEEDED field of the the nexe.
+ */
+
+INPUT ( -lppapi_simple_real )
+EXTERN ( __nacl_main PPP_InitializeModule )
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps.h b/native_client_sdk/src/libraries/ppapi_simple/ps.h
index 54a7d86..c1030f7 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/ps.h
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps.h
@@ -24,9 +24,9 @@ EXTERN_C_BEGIN
* will automatically start a new thread on which can be used effectively
* as a "main" entry point.
*
- * For C style development, the PPAPI_SIMPLE_REGISTER_MAIN(XX) macros provide a
- * mechanism to register the entry an point for "main". All events are pushed
- * onto an event queue which can then be pulled from this new thread.
+ * For C style development, ppapi_simple allows applications to be written using
+ * a traditaional "main". All events are pushed onto an event queue which can
+ * then be pulled from this new thread.
* NOTE: The link will still need libstdc++ and libppapi_cpp since the library
* is still creating a C++ object which does the initialization work and
* forwards the events.
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_entrypoints_c.c b/native_client_sdk/src/libraries/ppapi_simple/ps_entrypoints_c.c
index 9fe92c6..e698722 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/ps_entrypoints_c.c
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_entrypoints_c.c
@@ -9,11 +9,6 @@
#include "ppapi_simple/ps_interface.h"
#include "ppapi_simple/ps_internal.h"
-/* This is defined to allow an executable to force inclusion of this object
- * file. Otherwise PPP_* functions won't be linked in (because they are not
- * needed until -lppapi on the link-line, which is usually last. */
-FORCE_LINK_THIS(ps_entry)
-
int32_t PPP_InitializeModule(PP_Module module, PPB_GetInterface get_interface) {
g_ps_get_interface = get_interface;
PSInterfaceInit();
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_main.c b/native_client_sdk/src/libraries/ppapi_simple/ps_main.c
index 3923574..7d0d0b9 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/ps_main.c
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_main.c
@@ -4,20 +4,16 @@
#include "ppapi_simple/ps_main.h"
-#ifdef __native_client__
+#if defined(__native_client__)
+
#include <irt.h>
#include <irt_ppapi.h>
-#endif
#include <stdio.h>
#include "nacl_io/nacl_io.h"
#include "ppapi_simple/ps_instance.h"
-FORCE_LINK_THIS(ps_main)
-
-int PpapiPluginMain();
-
/**
* main entry point for ppapi_simple applications. This differs from the
* regular ppapi main entry point in that it will fall back to running
@@ -25,17 +21,21 @@ int PpapiPluginMain();
* This allows ppapi_simple binary to run within chrome (with PPAPI present)
* and also under sel_ldr (no PPAPI).
*/
-#ifdef __native_client__
+int PpapiPluginMain();
+
int __nacl_main(int argc, char* argv[]) {
struct nacl_irt_ppapihook hooks;
if (nacl_interface_query(NACL_IRT_PPAPIHOOK_v0_1, &hooks, sizeof(hooks)) ==
sizeof(hooks)) {
return PpapiPluginMain();
}
-#else
-int main(int argc, char* argv[]) {
-#endif
// By default, or if not running in the browser we simply run the main
// entry point directly, on the main thread.
return PSUserMainGet()(argc, argv);
}
+
+#elif defined(__APPLE__)
+
+int __nacl_main(int argc, char* argv[]) { return 0; }
+
+#endif
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_main.h b/native_client_sdk/src/libraries/ppapi_simple/ps_main.h
index 2ffcccd..22975ca 100644
--- a/native_client_sdk/src/libraries/ppapi_simple/ps_main.h
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_main.h
@@ -31,10 +31,6 @@ PSMainFunc_t PSUserMainGet();
* so we force them to be linked here.
*/
#define PPAPI_SIMPLE_REGISTER_MAIN(main_func) \
- EXTERN_C_BEGIN \
- FORCE_LINK_THAT(ps_entry) \
- FORCE_LINK_THAT(ps_main) \
- EXTERN_C_END \
PSMainFunc_t PSUserMainGet() { return main_func; }
EXTERN_C_END
diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_main_default.c b/native_client_sdk/src/libraries/ppapi_simple/ps_main_default.c
new file mode 100644
index 0000000..666b2f4
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_simple/ps_main_default.c
@@ -0,0 +1,10 @@
+/* Copyright 2015 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+/* Default main entry point for ppapi_simple is the main() symbol */
+#include "ppapi_simple/ps_main.h"
+
+int main(int argc, char **argv);
+
+PPAPI_SIMPLE_REGISTER_MAIN(main);
diff --git a/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc b/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc
index cb89709..2725897 100644
--- a/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi_simple_cpp/library.dsc
@@ -7,6 +7,14 @@
'TARGETS': [
{
'NAME' : 'ppapi_simple_cpp',
+ 'TYPE' : 'linker-script',
+ 'SOURCES' : [
+ "ppapi_simple_cpp.a.linkerscript",
+ "ppapi_simple_cpp.so.linkerscript",
+ ],
+ },
+ {
+ 'NAME' : 'ppapi_simple_cpp_real',
'TYPE' : 'lib',
'SOURCES' : [
"ps.c",
@@ -15,6 +23,7 @@
"ps_instance.c",
"ps_interface.c",
"ps_main.c",
+ "ps_main_default.c",
"ps_entrypoints_cpp.cc"
],
},
diff --git a/native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.a.linkerscript b/native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.a.linkerscript
new file mode 100644
index 0000000..c053c01
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.a.linkerscript
@@ -0,0 +1,10 @@
+/*
+ * Copyright 2015 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* When using pnacl-ld, -l<library name> doesn't work. */
+
+INPUT ( libppapi_simple_cpp_real.a )
+EXTERN ( PSUserMainGet __nacl_main PPP_InitializeModule )
diff --git a/native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.so.linkerscript b/native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.so.linkerscript
new file mode 100644
index 0000000..49ed059a
--- /dev/null
+++ b/native_client_sdk/src/libraries/ppapi_simple_cpp/ppapi_simple_cpp.so.linkerscript
@@ -0,0 +1,13 @@
+/*
+ * Copyright 2015 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * glibc requires -l<library name>. Using lib<library name>.{a,so} will end up
+ * adding the absolute path to the NEEDED field of the the nexe.
+ */
+
+INPUT ( -lppapi_simple_cpp_real )
+EXTERN ( PSUserMainGet PPP_InitializeModule )
diff --git a/native_client_sdk/src/libraries/ppapi_simple_cpp/ps_entrypoints_cpp.cc b/native_client_sdk/src/libraries/ppapi_simple_cpp/ps_entrypoints_cpp.cc
index 01760ae..532bcd1 100644
--- a/native_client_sdk/src/libraries/ppapi_simple_cpp/ps_entrypoints_cpp.cc
+++ b/native_client_sdk/src/libraries/ppapi_simple_cpp/ps_entrypoints_cpp.cc
@@ -32,7 +32,7 @@ Module* Module::Get() {
return s_module;
}
-// This shouldn't be called (it is only referenced by PPP_InitialzeModule in
+// This shouldn't be called (it is only referenced by PPP_InitializeModule in
// ppapi_cpp, which we override), but is needed to successfully link.
Module* CreateModule() {
assert(0);
@@ -41,15 +41,6 @@ Module* CreateModule() {
} // namespace pp
-extern "C" {
-
-// This is defined to allow an executable to force inclusion of this object
-// file. Otherwise PPP_* functions won't be linked in (because they are not
-// needed until -lppapi on the link-line, which is usually last.
-FORCE_LINK_THIS(ps_entry)
-
-} // extern "C"
-
int32_t PPP_InitializeModule(PP_Module module_id,
PPB_GetInterface get_interface) {
g_ps_get_interface = get_interface;
diff --git a/native_client_sdk/src/libraries/sdk_util/macros.h b/native_client_sdk/src/libraries/sdk_util/macros.h
index b1bc75e..1ead15d2 100644
--- a/native_client_sdk/src/libraries/sdk_util/macros.h
+++ b/native_client_sdk/src/libraries/sdk_util/macros.h
@@ -29,24 +29,6 @@
#endif /* __cplusplus */
/**
- * Macros to help force linkage of symbols that otherwise would not be
- * included.
- *
- * // In a source file that you want to force linkage (file scope):
- * FORCE_LINK_THIS(myfilename);
- *
- * // In a source file that you are sure will be linked (file scope):
- * FORCE_LINK_THAT(myfilename)
- *
- */
-#define FORCE_LINK_THIS(x) int force_link_##x = 0;
-#define FORCE_LINK_THAT(x) \
- void force_link_function_##x() { \
- extern int force_link_##x; \
- force_link_##x = 1; \
- }
-
-/**
* Macro to error out when a printf-like function is passed incorrect arguments.
*
* Use like this:
diff --git a/native_client_sdk/src/resources/Makefile.example.template b/native_client_sdk/src/resources/Makefile.example.template
index c511964..aef08ef 100644
--- a/native_client_sdk/src/resources/Makefile.example.template
+++ b/native_client_sdk/src/resources/Makefile.example.template
@@ -72,6 +72,7 @@ ifneq ($(TOOLCHAIN),pnacl)
endif
[[ ]]
{{sources}} = {{source_list}}
+[[]]
# Build rules generated by macros from common.mk:
diff --git a/native_client_sdk/src/resources/Makefile.library.template b/native_client_sdk/src/resources/Makefile.library.template
index 5687355..92b9452 100644
--- a/native_client_sdk/src/resources/Makefile.library.template
+++ b/native_client_sdk/src/resources/Makefile.library.template
@@ -39,22 +39,30 @@ include $(NACL_SDK_ROOT)/tools/common.mk
[[ExpandDict('DEPS', targets[0].get('DEPS', []))]]
[[ExpandDict('LIBS', targets[0].get('LIBS', []), pre_list=['$(DEPS)'])]]
-[[flags = target.get('CFLAGS', [])]]
-[[flags.extend(target.get('CXXFLAGS', []))]]
-[[ExpandDict('CFLAGS', flags)]]
-[[if 'CFLAGS_GCC' in target:]]
+
+[[for target in targets:]]
+[[ if target['TYPE'] != 'linker-script':]]
+[[ source_list = (s for s in sorted(target['SOURCES']) if not s.endswith('.h'))]]
+[[ source_list = ' \\\n '.join(source_list)]]
+[[ sources = target['NAME'] + '_SOURCES']]
+[[ cflags = target['NAME'] + '_CFLAGS']]
+[[ flags = target.get('CFLAGS', [])]]
+[[ flags.extend(target.get('CXXFLAGS', []))]]
+[[ if len(targets) == 1:]]
+[[ sources = 'SOURCES']]
+[[ cflags = 'CFLAGS']]
+[[ ]]
+[[ ExpandDict(cflags, flags)]]
+[[ for define in target.get('DEFINES', []):]]
+{{cflags}} += -D{{define}}
+[[ ]]
+[[ if 'CFLAGS_GCC' in target:]]
ifneq ($(TOOLCHAIN),pnacl)
-CFLAGS += {{' '.join(target['CFLAGS_GCC'])}}
+{{cflags}} += {{' '.join(target['CFLAGS_GCC'])}}
endif
-[[]]
-
-[[for define in target.get('DEFINES', []):]]
-CFLAGS += -D{{define}}
-[[]]
+[[ ]]
+{{sources}} = {{source_list}}
-SOURCES = \
-[[for source in sorted(target['SOURCES']):]]
- {{source}} \
[[]]
all: install
@@ -63,13 +71,22 @@ all: install
[[if targets[0].get('DEPS'):]]
$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
-[[]]
-$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
-$(eval $(call LIB_RULE,$(TARGET),$(SOURCES)))
-
-[[if target['TYPE'] != 'static-lib':]]
+[[for target in targets:]]
+[[ name = target['NAME'] ]]
+[[ if len(targets) == 1:]]
+[[ sources = 'SOURCES']]
+[[ cflags = 'CFLAGS']]
+[[ else:]]
+[[ sources = name + '_SOURCES']]
+[[ cflags = name + '_CFLAGS']]
+[[ if target['TYPE'] == 'linker-script':]]
+$(eval $(call LINKER_SCRIPT_RULE,{{name}},{{target['SOURCES'][0]}},{{target['SOURCES'][1]}}))
+[[ else:]]
+$(foreach src,$({{sources}}),$(eval $(call COMPILE_RULE,$(src),$({{cflags}}))))
+$(eval $(call LIB_RULE,{{name}},$({{sources}})))
+[[ if target['TYPE'] != 'static-lib':]]
ifneq (,$(findstring $(TOOLCHAIN),glibc bionic))
-$(eval $(call SO_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
+$(eval $(call SO_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS)))
endif
-[[]]
+[[ ]]
{{post}}
diff --git a/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc b/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc
index 7d9a593..ec4379b 100644
--- a/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc
+++ b/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc
@@ -10,9 +10,7 @@
'echo_server.cc',
'echo_server.h',
],
- 'DEPS': ['ppapi_simple', 'nacl_io'],
- # Order matters here: gtest has a "main" function that will be used if
- # referenced before ppapi.
+ 'DEPS': ['ppapi_simple_cpp', 'nacl_io'],
'LIBS': ['ppapi_simple_cpp', 'ppapi_cpp', 'gmock', 'ppapi', 'gtest', 'nacl_io', 'pthread'],
'CXXFLAGS': ['-Wno-sign-compare']
}
diff --git a/native_client_sdk/src/tests/nacl_io_socket_test/main.cc b/native_client_sdk/src/tests/nacl_io_socket_test/main.cc
index 61066a2..e7ed5b8 100644
--- a/native_client_sdk/src/tests/nacl_io_socket_test/main.cc
+++ b/native_client_sdk/src/tests/nacl_io_socket_test/main.cc
@@ -5,6 +5,7 @@
#include <string>
#include "gtest/gtest.h"
+
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/var.h"
#include "ppapi_simple/ps_main.h"
@@ -42,7 +43,7 @@ class GTestEventListener : public ::testing::EmptyTestEventListener {
}
};
-int example_main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
if (PSGetInstanceId() != 0) {
::testing::UnitTest::GetInstance()->listeners()
@@ -50,7 +51,3 @@ int example_main(int argc, char* argv[]) {
}
return RUN_ALL_TESTS();
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/tests/nacl_io_test/example.dsc b/native_client_sdk/src/tests/nacl_io_test/example.dsc
index 43d588c..08899cd 100644
--- a/native_client_sdk/src/tests/nacl_io_test/example.dsc
+++ b/native_client_sdk/src/tests/nacl_io_test/example.dsc
@@ -61,9 +61,7 @@
'socket_test.cc',
'tty_test.cc',
],
- 'DEPS': ['ppapi_simple', 'nacl_io'],
- # Order matters here: gtest has a "main" function that will be used if
- # referenced before ppapi.
+ 'DEPS': ['ppapi_simple_cpp', 'nacl_io'],
'LIBS': ['ppapi_simple_cpp', 'ppapi_cpp', 'gmock', 'nacl_io', 'ppapi', 'gtest', 'pthread'],
'INCLUDES': ["."],
'CXXFLAGS': ['-Wno-sign-compare'],
diff --git a/native_client_sdk/src/tests/nacl_io_test/main.cc b/native_client_sdk/src/tests/nacl_io_test/main.cc
index 31414e6..0db0151 100644
--- a/native_client_sdk/src/tests/nacl_io_test/main.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/main.cc
@@ -42,7 +42,7 @@ class GTestEventListener : public ::testing::EmptyTestEventListener {
}
};
-int example_main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
setenv("TERM", "xterm-256color", 0);
::testing::InitGoogleTest(&argc, argv);
if (PSGetInstanceId() != 0) {
@@ -51,7 +51,3 @@ int example_main(int argc, char* argv[]) {
}
return RUN_ALL_TESTS();
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/tests/sdk_util_test/example.dsc b/native_client_sdk/src/tests/sdk_util_test/example.dsc
index 63b89ba..334d1da 100644
--- a/native_client_sdk/src/tests/sdk_util_test/example.dsc
+++ b/native_client_sdk/src/tests/sdk_util_test/example.dsc
@@ -10,9 +10,7 @@
'main.cc',
'string_util_test.cc',
],
- 'DEPS': ['ppapi_simple', 'sdk_util', 'nacl_io'],
- # Order matters here: gtest has a "main" function that will be used if
- # referenced before ppapi.
+ 'DEPS': ['ppapi_simple_cpp', 'sdk_util', 'nacl_io'],
'LIBS': ['ppapi_simple_cpp', 'ppapi_cpp', 'gmock', 'nacl_io', 'ppapi', 'gtest', 'pthread'],
'CXXFLAGS': ['-Wno-sign-compare']
}
diff --git a/native_client_sdk/src/tests/sdk_util_test/main.cc b/native_client_sdk/src/tests/sdk_util_test/main.cc
index a715b1b..eb2a8ea 100644
--- a/native_client_sdk/src/tests/sdk_util_test/main.cc
+++ b/native_client_sdk/src/tests/sdk_util_test/main.cc
@@ -42,7 +42,7 @@ class GTestEventListener : public ::testing::EmptyTestEventListener {
}
};
-int example_main(int argc, char* argv[]) {
+int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
if (PSGetInstanceId() != 0) {
::testing::UnitTest::GetInstance()->listeners()
@@ -50,7 +50,3 @@ int example_main(int argc, char* argv[]) {
}
return RUN_ALL_TESTS();
}
-
-// Register the function to call once the Instance Object is initialized.
-// see: pappi_simple/ps_main.h
-PPAPI_SIMPLE_REGISTER_MAIN(example_main);
diff --git a/native_client_sdk/src/tools/host_gcc.mk b/native_client_sdk/src/tools/host_gcc.mk
index 6c98369..4c82008 100644
--- a/native_client_sdk/src/tools/host_gcc.mk
+++ b/native_client_sdk/src/tools/host_gcc.mk
@@ -35,8 +35,14 @@ CC = $(NACL_COMPILER_PREFIX) $(CC)
CXX = $(NACL_COMPILER_PREFIX) $(CXX)
endif
+ifeq ($(OSNAME),mac)
+LINK ?= $(NACL_SDK_ROOT)/tools/mac_ld_wrapper.py $(CXX)
+#AR = libtool -static -no_warning_for_no_symbols
+#ARFLAGS = -o
+else
LINK ?= $(CXX)
-AR ?= ar
+endif
+AR = ar
ARFLAGS = -crs
STRIP ?= strip
@@ -182,6 +188,31 @@ define LINK_RULE
$(call LINKER_RULE,$(OUTDIR)/$(1)$(HOST_EXT),$(foreach src,$(2),$(call SRC_TO_OBJ,$(src))),$(filter-out pthread,$(3)),$(4),$(LIB_PATHS),$(5))
endef
+
+#
+# Macro to generate linker scripts
+#
+# $1 = Target Name
+# $2 = Static Linker Script
+# $3 = Shared Linker Script
+#
+define LINKER_SCRIPT_RULE
+$(STAMPDIR)/$(1).stamp:
+ @echo " STAMP $$@"
+ @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
+
+install: $(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a
+$(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).a: $(2)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+
+install: $(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).so
+$(LIBDIR)/$(OSNAME)_host/$(CONFIG)/lib$(1).so: $(3)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endef
+
+
all: $(LIB_LIST) $(DEPS_LIST)
diff --git a/native_client_sdk/src/tools/mac_ld_wrapper.py b/native_client_sdk/src/tools/mac_ld_wrapper.py
new file mode 100755
index 0000000..22c24f7
--- /dev/null
+++ b/native_client_sdk/src/tools/mac_ld_wrapper.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Wrapper script OSX native linker to handle lack of linker script support.
+"""
+
+import sys
+import os
+
+SYMS = ('PSUserMainGet', '__nacl_main', 'PPP_InitializeModule')
+
+debug = False
+
+def main(args):
+ assert(args)
+ if '-lppapi_simple' in args:
+ args[args.index('-lppapi_simple')] = '-lppapi_simple_real'
+ for s in SYMS:
+ args += ['-Wl,-u', '-Wl,_' + s]
+
+ if '-lppapi_simple_cpp' in args:
+ args[args.index('-lppapi_simple_cpp')] = '-lppapi_simple_cpp_real'
+ for s in SYMS:
+ args += ['-Wl,-u', '-Wl,_' + s]
+
+ if debug:
+ print ' '.join(args)
+ os.execvp(args[0], args)
+ # should never get here
+ return 1
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
diff --git a/native_client_sdk/src/tools/nacl_gcc.mk b/native_client_sdk/src/tools/nacl_gcc.mk
index 29a8602..f4fd613 100644
--- a/native_client_sdk/src/tools/nacl_gcc.mk
+++ b/native_client_sdk/src/tools/nacl_gcc.mk
@@ -383,6 +383,70 @@ endef
#
+# Macro to generate linker scripts
+#
+# $1 = Target Name
+# $2 = Static Linker Script
+# $3 = Shared Linker Script
+#
+define LINKER_SCRIPT_RULE
+$(STAMPDIR)/$(1).stamp:
+ @echo " STAMP $$@"
+ @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
+
+ifneq (,$(findstring x86_32,$(ARCHES)))
+$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a
+install: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a
+$(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a: $(2)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endif
+
+ifneq (,$(findstring x86_64,$(ARCHES)))
+$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a
+install: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a
+$(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a: $(2)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endif
+
+ifneq (,$(findstring arm,$(ARCHES)))
+$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a
+install: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a
+$(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a: $(2)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endif
+
+ifeq ($(TOOLCHAIN),glibc)
+ifneq (,$(findstring x86_32,$(ARCHES)))
+$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).so
+install: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).so
+$(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).so: $(3)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endif
+
+ifneq (,$(findstring x86_64,$(ARCHES)))
+$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).so
+install: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).so
+$(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).so: $(3)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endif
+
+ifneq (,$(findstring arm,$(ARCHES)))
+$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).so
+install: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).so
+$(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).so: $(3)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endif
+endif
+endef
+
+
+#
# Strip Macro for each arch (e.g., each arch supported by LINKER_RULE).
#
# $1 = Target Name
diff --git a/native_client_sdk/src/tools/nacl_llvm.mk b/native_client_sdk/src/tools/nacl_llvm.mk
index 46b2a04..c16f3d1 100644
--- a/native_client_sdk/src/tools/nacl_llvm.mk
+++ b/native_client_sdk/src/tools/nacl_llvm.mk
@@ -129,6 +129,24 @@ endef
#
+# Macro to generate linker scripts
+#
+# $1 = Target Name
+# $2 = Linker Script
+#
+define LINKER_SCRIPT_RULE
+$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a
+ @echo " STAMP $$@"
+ @echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
+
+install: $(LIBDIR)/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a
+$(LIBDIR)/$(TOOLCHAIN)/$(CONFIG)/lib$(1).a: $(2)
+ $(MKDIR) -p $$(dir $$@)
+ $(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
+endef
+
+
+#
# Strip Macro
#
# NOTE: pnacl-strip does not really do much for finalized pexes (in a