Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

centos7 collect2: error: ld returned 1 exit status #64

Open
shijunti19 opened this issue Jun 7, 2019 · 12 comments
Open

centos7 collect2: error: ld returned 1 exit status #64

shijunti19 opened this issue Jun 7, 2019 · 12 comments
Assignees
Labels
🐞 bug Something isn't working 📦 component-extension About the PHP extension written in C/C++

Comments

@shijunti19
Copy link

shijunti19 commented Jun 7, 2019

centos 7
php7.3

creating libtool
appending configuration tag "CXX" to libtool
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... 
checking if g++ static flag  works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... unsupported
configure: creating ./config.status
config.status: creating config.h
/bin/sh /xiaolu/root/php-ext-wasm/extension/libtool --mode=compile g++  -I. -I/xiaolu/root/php-ext-wasm/extension -DPHP_ATOM_INC -I/xiaolu/root/php-ext-wasm/extension/include -I/xiaolu/root/php-ext-wasm/extension/main -I/xiaolu/root/php-ext-wasm/extension -I/www/server/php/73/include/php -I/www/server/php/73/include/php/main -I/www/server/php/73/include/php/TSRM -I/www/server/php/73/include/php/Zend -I/www/server/php/73/include/php/ext -I/www/server/php/73/include/php/ext/date/lib  -DHAVE_CONFIG_H  -std=c++11   -c /xiaolu/root/php-ext-wasm/extension/wasm.cc -o wasm.lo 
mkdir .libs
 g++ -I. -I/xiaolu/root/php-ext-wasm/extension -DPHP_ATOM_INC -I/xiaolu/root/php-ext-wasm/extension/include -I/xiaolu/root/php-ext-wasm/extension/main -I/xiaolu/root/php-ext-wasm/extension -I/www/server/php/73/include/php -I/www/server/php/73/include/php/main -I/www/server/php/73/include/php/TSRM -I/www/server/php/73/include/php/Zend -I/www/server/php/73/include/php/ext -I/www/server/php/73/include/php/ext/date/lib -DHAVE_CONFIG_H -std=c++11 -c /xiaolu/root/php-ext-wasm/extension/wasm.cc  -DPIC -o .libs/wasm.o
/bin/sh /xiaolu/root/php-ext-wasm/extension/libtool --mode=link cc -DPHP_ATOM_INC -I/xiaolu/root/php-ext-wasm/extension/include -I/xiaolu/root/php-ext-wasm/extension/main -I/xiaolu/root/php-ext-wasm/extension -I/www/server/php/73/include/php -I/www/server/php/73/include/php/main -I/www/server/php/73/include/php/TSRM -I/www/server/php/73/include/php/Zend -I/www/server/php/73/include/php/ext -I/www/server/php/73/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2    -o wasm.la -export-dynamic -avoid-version -prefer-pic -module -rpath /xiaolu/root/php-ext-wasm/extension/modules  wasm.lo -Wl,-rpath,/xiaolu/root/php-ext-wasm/extension/. -L/xiaolu/root/php-ext-wasm/extension/. -lwasmer_runtime_c_api
cc -shared  .libs/wasm.o  -L/xiaolu/root/php-ext-wasm/extension/. -lwasmer_runtime_c_api  -Wl,-rpath -Wl,/xiaolu/root/php-ext-wasm/extension/. -Wl,-soname -Wl,wasm.so -o .libs/wasm.so
/usr/bin/ld: .libs/wasm.o: relocation R_X86_64_32S against symbol `wasm_array_buffer_class_entry_handlers' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [wasm.la] 错误 1
error: Recipe `php` failed with exit code 2
@shijunti19 shijunti19 added the 🐞 bug Something isn't working label Jun 7, 2019
@Hywan Hywan self-assigned this Jun 11, 2019
@Hywan
Copy link
Contributor

Hywan commented Jun 11, 2019

Ah, this -fPIC error… I don't know how to fix it yet, except by running gcc by hand as I did for CircleCI. Let's keep this issue opened for the moment the time I find a solution.

@Hywan Hywan added the 📦 component-extension About the PHP extension written in C/C++ label Jun 11, 2019
@suhanyujie
Copy link

(⊙o⊙)… I've met the trouble too

@yejune
Copy link

yejune commented Aug 24, 2019

ubuntu bionic
php 7.3

same

@Hywan
Copy link
Contributor

Hywan commented Aug 28, 2019

How do you build the extension?

@janbuecker
Copy link

janbuecker commented Oct 9, 2019

EDIT: Nevermind, i've put the source of this extension on a non-persistant storage. It now works.


When using the instructions from the CircleCI configuration, the extension gets compiled, but cannot be loaded. Any advice here?

PHP Warning:  PHP Startup: Unable to load dynamic library 'wasm.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/wasm.so (libwasmer_runtime_c_api.so: failed to map segment from shared object)) in Unknown on line 0

on PHP 7.2

PHP Warning:  PHP Startup: Unable to load dynamic library 'wasm.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20170718/wasm.so (libwasmer_runtime_c_api.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

@Hywan
Copy link
Contributor

Hywan commented Dec 9, 2019

Maybe the provided shared library isn't compatible for your system.

In #99, I've introduced a new command just build-runtime. Can you run it first? It will compile a shared library specifically for your system.

@shijunti19
Copy link
Author

@Hywan
image

@Hywan
Copy link
Contributor

Hywan commented Jan 22, 2020

@shijunti19 What version of Rust do you have? Is it up-to-date?

@shijunti19
Copy link
Author

shijunti19 commented Jan 24, 2020

@Hywan
ok
php 7.3.13
rust 1.14

  Compiling php-ext-wasm v0.5.0 (/longteng/soft/php-ext-wasm)
    Finished release [optimized] target(s) in 6m 41s
ln: 无法创建符号链接"wasmer/libwasmer_runtime_c_api.so": 没有那个文件或目录
error: Recipe `build-runtime` failed with exit code 1

@shijunti19
Copy link
Author

just build

/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make: *** [wasm.la] 错误 1
error: Recipe `build` failed with exit code 2

@DeppLearning
Copy link

DeppLearning commented Jan 28, 2020

I experienced the same problems on Manjaro Linux 18.1.5 running php 7.4.2 and rust 1.40.0

I can at least run the example/simple.php file when I add the -fPIC flag here:
https://github.com/wasmerio/php-ext-wasm/blob/6b02d0f1a853ba270bafa6f2b123e29c47dfbac7/justfile#L47
, like so:

export CXXFLAGS='-std=c++11 -fPIC'

Thanks for making this, looking forward to experiment more with rust, wasm and php.

@Hywan
Copy link
Contributor

Hywan commented Feb 10, 2020

@shijunti19 You can update Rust (1.41 is the current version), but it won't solve the problem I guess.

@DeppLearning Some platforms need PIC, some others don't. I don't know exactly how to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 component-extension About the PHP extension written in C/C++
Projects
None yet
Development

No branches or pull requests

6 participants