2

I am trying to build Python 3.4 from source, using emscripten.

I have downloaded and successfully installed emscripten. I have created a build folder outside the source tree. These are the steps I have carried out so far:

  1. Run configure: $ emconfigure ../Python-3.4.3/configure --without-threads --without-pymalloc --enable-shared --disable-ipv6 --build=i686-linux-gnu

  2. I noticed that a check for LONG_BIT in ../Python-3.4.3/Include/pyport.h conflicts with the #define SIZEOF_LONG defined in one of emscriptens headers, so I have commented out the check in ../Python-3.4.3/Include/pyport.h

  3. After running configure successfully, I then run emmmake make in my build folder

  4. I check that the built python file is indeed LLVM bytecode by running file python. Having satisfied myself that all is well, I attempt to link the generated libpython3-4.so with the bytecode as follows:

$ llvm-link libpython3.4.so python -o python.bc

I get the following error message:

ERROR: Linking globals named '_Py_open_cloexec_works': symbol multiply defined!

A quick search through the source code shows the symbol is NOT multiply defined:

$ grep -rnw ../Python-3.4.3 -e "_Py_open_cloexec_works" --include=\*.{c,h}
../Python-3.4.3/Python/fileutils.c:33:int _Py_open_cloexec_works = -1;
../Python-3.4.3/Python/fileutils.c:784:    atomic_flag_works = &_Py_open_cloexec_works;
../Python-3.4.3/Modules/posixmodule.c:7702:extern int _Py_open_cloexec_works;
../Python-3.4.3/Modules/posixmodule.c:7725:    int *atomic_flag_works = &_Py_open_cloexec_works;
../Python-3.4.3/Modules/_io/fileio.c:210:extern int _Py_open_cloexec_works;
../Python-3.4.3/Modules/_io/fileio.c:232:    int *atomic_flag_works = &_Py_open_cloexec_works;

So I run nm on libpython3.4.so, to check the exported symbols, and I got the following error message:

nm: libpython3.4.so: File format not recognised

I have run out of ideas now. Can anyone help me solve the linkage issues?

[[ Additional Info ]]

  • clang version 3.6.0
  • LLVM version 3.6.0svn

1 Answer 1

0

Instead of nm, you can use the powerful objdump. Try objdump -t you_file or objdump -T you_file.

Example: objdump -t lib.o

Sign up to request clarification or add additional context in comments.

2 Comments

I just checked the file type for the generated .so file. It turns out its LLVM bitcode, so nm and objdump both do not recognise the file format.
Try to compile python with g++5 , for me worked perfect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.