KnoooW / naclports

Automatically exported from code.google.com/p/naclports
0 stars 0 forks source link

SDL pnacl build fails, missing c++ symbols #98

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Downloaded naclports, svn rev 1002 or later.

Build SDL on pnacl with:

NACL_ARCH=pnacl make sdl

After the configure step, the build fails with this output:

Build SDL-1.2.14
######################################################################
Directory: 
/Users/afischer/naclports/src/out/repository/SDL-1.2.14/build-nacl-pnacl-test
make -j4
/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/bin/pnacl-clang -o 
checkkeys.pexe ../test/checkkeys.c -I/Users/afischer/nacl/pepper_31/include -O2 
-I/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/include/SDL 
-D_GNU_SOURCE=1 -D_REENTRANT 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib 
-L/Users/afischer/nacl/pepper_31/lib/pnacl/Release -O2 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib -Wl,--start-group 
-lSDLmain -lSDL -lppapi -lppapi_cpp -lppapi_gles2 -Wl,--end-group -lc++ 
-lpthread -lm -lpthread -lnacl_io -lc++
/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/bin/pnacl-clang -o 
graywin.pexe ../test/graywin.c -I/Users/afischer/nacl/pepper_31/include -O2 
-I/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/include/SDL 
-D_GNU_SOURCE=1 -D_REENTRANT 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib 
-L/Users/afischer/nacl/pepper_31/lib/pnacl/Release -O2 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib -Wl,--start-group 
-lSDLmain -lSDL -lppapi -lppapi_cpp -lppapi_gles2 -Wl,--end-group -lc++ 
-lpthread -lm -lpthread -lnacl_io -lc++
/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/bin/pnacl-clang -o 
loopwave.pexe ../test/loopwave.c -I/Users/afischer/nacl/pepper_31/include -O2 
-I/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/include/SDL 
-D_GNU_SOURCE=1 -D_REENTRANT 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib 
-L/Users/afischer/nacl/pepper_31/lib/pnacl/Release -O2 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib -Wl,--start-group 
-lSDLmain -lSDL -lppapi -lppapi_cpp -lppapi_gles2 -Wl,--end-group -lc++ 
-lpthread -lm -lpthread -lnacl_io -lc++
/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/bin/pnacl-clang -o 
testalpha.pexe ../test/testalpha.c -I/Users/afischer/nacl/pepper_31/include -O2 
-I/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/include/SDL 
-D_GNU_SOURCE=1 -D_REENTRANT 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib 
-L/Users/afischer/nacl/pepper_31/lib/pnacl/Release -O2 
-L/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib -Wl,--start-group 
-lSDLmain -lSDL -lppapi -lppapi_cpp -lppapi_gles2 -Wl,--end-group -lc++ 
-lpthread -lm -lpthread -lnacl_io -lc++ -lm
/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib/libSDL.a: error: 
undefined reference to 'std::string::_Rep::_M_destroy(std::allocator<char> 
const&)'
/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib/libSDL.a: error: 
undefined reference to 'std::string::_Rep::_S_empty_rep_storage'
/Users/afischer/nacl/pepper_31/toolchain/mac_pnacl/usr/lib/libSDL.a: error: 
undefined reference to 'std::string::_M_leak_hard()'
/Users/afischer/nacl/pepper_31/lib/pnacl/Release/libppapi_cpp.a: error: 
undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'
/Users/afischer/nacl/pepper_31/lib/pnacl/Release/libppapi_cpp.a: error: 
undefined reference to 
'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, 
std::_Rb_tree_node_base&)'
/Users/afischer/nacl/pepper_31/lib/pnacl/Release/libppapi_cpp.a: error: 
undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'
(snip)

What version of the product are you using? On what operating system?

Pepper 31 on OSX 10.9

Please provide any additional information below.

I did some bisecting and found that this build started failing with r1000 
("Prepare naclports for the PNaCl change to libc++ as the default."), although 
that rev gives a different error. The error quoted above seems to happen on 
r1002 and later.

Also for reference, building with NACL_ARCH=i686 works successfully.

Original issue reported on code.google.com by andy.fis...@gmail.com on 11 Dec 2013 at 2:04

GoogleCodeExporter commented 9 years ago
Looks like a problem with https://codereview.chromium.org/92733002.

I think this change should only have changed C++ library to c++ for pepper_33
and above.   In pepper_32 and below the default library was still stdc++ and
naclports should mirror this.

jf, can you take a look?

Original comment by sbc@google.com on 11 Dec 2013 at 2:35

GoogleCodeExporter commented 9 years ago
The naclports change was done mainly to work around the forced linking to 
libstdc++ because of the nacl_io dependency on the C++ standard library.

It force-link libstdc++ for non-PNaCl builds, and force-links libc++ for PNaCl 
builds since that is now the default in the current canary SDK.

This means that naclports has to be in-sync with the SDK, using the latest 
naclports therefore only works with the latest SDK.

It could be possible to fix this by changing the forced-linking logic to detect 
the SDK version and only apply the change on 32 and previous. Or the canary SDK 
could be used instead :-)

Original comment by j...@google.com on 11 Dec 2013 at 5:33

GoogleCodeExporter commented 9 years ago
FWIW the change to "fix" this prior to version 33 would be to change line 103 
of common.sh to:

if [ "${NACL_ARCH}" = "pnacl" -a ${NACL_SDK_VERSION} -gt 32 ]; then

I think it also needs to move down since NACL_SDK_VERSION is defined at 187.

Original comment by j...@chromium.org on 11 Dec 2013 at 6:36

GoogleCodeExporter commented 9 years ago
That looks like the correct fix, yes.

Original comment by sbc@chromium.org on 11 Dec 2013 at 6:41

GoogleCodeExporter commented 9 years ago

Original comment by sbc@google.com on 30 Sep 2014 at 11:20