ponylang / ponyc

Pony is an open-source, actor-model, capabilities-secure, high performance programming language
http://www.ponylang.io
BSD 2-Clause "Simplified" License
5.68k stars 409 forks source link

ponyc unable to link programs on Alpine 3.10 rc2 #3170

Closed Cogitri closed 5 years ago

Cogitri commented 5 years ago

Hello there,

I'm currently in the process of updating ponyc to 0.28.1 on Alpine Linux Edge. Building anything (e.g. pony-stable) fails though:

...
Optimising
Writing build/release/stable.o
Linking build/release/stable
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: error: cannot find -lexecinfo
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: build/release/stable: No error information
collect2: error: ld returned 1 exit status
Warning: environment variable $CC undefined, using gcc as the linker
Error:
unable to link: gcc -o build/release/stable -O3 -march=native -mcx16 -latomic  -fuse-ld=gold build/release/stable.o -L"/usr/lib/pony/0.28.1/bin/" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/" -L"/usr/lib/pony/0.28.1/bin/../lib/native" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../lib/native" -L"/usr/lib/pony/0.28.1/bin/../packages" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../packages" -L"/usr/local/lib" -Wl,-rpath,"/usr/local/lib" -Wl,--start-group -l"rt" -Wl,--end-group  -lpthread  -lponyrt-pic -ldl -lm -lexecinfo 

ponyc -v:

ponyc -v
0.28.1 [release]
compiled with: llvm 6.0.1 -- gcc (Alpine 8.3.0) 8.3.0
Defaults: pic=true ssl=openssl_0.9.0

See https://github.com/alpinelinux/aports/pull/8626/files for the APKBUILD I use for building ponyc.

The crash seems to be related to https://sourceware.org/bugzilla/show_bug.cgi?id=23856.

SeanTAllen commented 5 years ago

It would appear that the execinfo library isn't installed and is required.

see: error: cannot find -lexecinfo

Cogitri commented 5 years ago

Ah, sorry, pasted the wrong log (from my native host and not in docker) - this is the right one:

Optimising
Writing build/release/stable.o
Linking build/release/stable
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: build/release/stable: No error information
collect2: error: ld returned 1 exit status
Error:
unable to link: gcc -o build/release/stable -O3 -march=native -mcx16 -latomic  -fuse-ld=gold build/release/stable.o -L"/usr/lib/pony/0.28.1/bin/" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/" -L"/usr/lib/pony/0.28.1/bin/../lib/native" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../lib/native" -L"/usr/lib/pony/0.28.1/bin/../packages" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../packages" -L"/usr/local/lib" -Wl,-rpath,"/usr/local/lib" -Wl,--start-group -l"rt" -Wl,--end-group  -lpthread  -lponyrt-pic -ldl -lm -lexecinfo 
make: *** [Makefile:43: build/release/stable] Error 255
SeanTAllen commented 5 years ago

The docker container using Alpine builds fine (and plenty of folks use for building programs after that). First step would be to investigate what is different about your environment:

https://github.com/ponylang/ponyc/blob/master/.dockerhub/alpine/Dockerfile

I'm imagining that a lot has changed since Alpine 3.9 with the Alpine you are using?

Cogitri commented 5 years ago

This is on Alpine Linux Edge, which will be released as 3.10 soon (it's currently equivalent to 3.10-rc2)

SeanTAllen commented 5 years ago

What happens if you run:

gcc -o build/release/stable -O3 -march=native -mcx16 -latomic -fuse-ld=gold build/release/stable.o -L"/usr/lib/pony/0.28.1/bin/" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/" -L"/usr/lib/pony/0.28.1/bin/../lib/native" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../lib/native" -L"/usr/lib/pony/0.28.1/bin/../packages" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../packages" -L"/usr/local/lib" -Wl,-rpath,"/usr/local/lib" -Wl,--start-group -l"rt" -Wl,--end-group -lpthread -lponyrt-pic -ldl -lm -lexecinfo

directly?

Cogitri commented 5 years ago

The exact same thing:

gcc -o build/release/stable -O3 -march=native -mcx16 -latomic -fuse-ld=gold build/release/stable.o -L"/usr/lib/pony/0.28.1/bin/" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/" -L"/usr/lib/pony/0.28.1/bin/../lib/native" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../lib/native" -L"/usr/lib/pony/0.28.1/bin/../packages" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../packages" -L"/usr/local/lib" -Wl,-rpath,"/usr/local/lib" -Wl,--start-group -l"rt" -Wl,--end-group -lpthread -lponyrt-pic -ldl -lm -lexecinfo
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: build/release/stable: No error information
collect2: error: ld returned 1 exit status
jemc commented 5 years ago

Can you try with -fPIE added to that invocation, as mentioned in this comment in bugzilla (https://sourceware.org/bugzilla/show_bug.cgi?id=23856#c2)?

gcc -o build/release/stable -O3 -march=native -mcx16 -latomic -fuse-ld=gold build/release/stable.o -L"/usr/lib/pony/0.28.1/bin/" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/" -L"/usr/lib/pony/0.28.1/bin/../lib/native" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../lib/native" -L"/usr/lib/pony/0.28.1/bin/../packages" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../packages" -L"/usr/local/lib" -Wl,-rpath,"/usr/local/lib" -Wl,--start-group -l"rt" -Wl,--end-group -lpthread -lponyrt-pic -ldl -lm -lexecinfo -fPie

Cogitri commented 5 years ago

Same thing:

gcc -o build/release/stable -O3 -march=native -mcx16 -latomic -fuse-ld=gold build/release/stable.o -L"/usr/lib/pony/0.28.1/bin/" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/" -L"/usr/lib/pony/0.28.1/bin/../lib/native" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../lib/native" -L"/usr/lib/pony/0.28.1/bin/../packages" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../packages" -L"/usr/local/lib" -Wl,-rpath,"/usr/local/lib" -Wl,--start-group -l"rt" -Wl,--end-group -lpthread -lponyrt-pic -ldl -lm -lexecinfo -fPIE
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: build/release/stable: No error information
collect2: error: ld returned 1 exit status
dipinhora commented 5 years ago

I'm unable to reproduce this on Alpine 3.10 via docker. I ran everything in the following docker container:

sudo docker run -it --rm alpine

The commands I ran were the following:

apk add --update \
  alpine-sdk \
  libressl-dev \
  binutils-gold \
  pcre2-dev \
  libexecinfo-dev \
  coreutils \
  linux-headers \
  cmake \
  python

I installed llvm 7 instead of llvm 6 because alpine 3.10 doesn't have pre-built packages for llvm 6.

apk add --update llvm7-dev
git clone https://github.com/ponylang/ponyc

I tried both master and tag 0.28.1 without running into issues.

make default_pic=true LLVM_CONFIG=llvm7-config

Output showing OS version, ponyc version, and compiling pony-stable successfully:

/ponyc # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.10.0
PRETTY_NAME="Alpine Linux v3.10"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/ponyc # cd pony-stable/
/ponyc/pony-stable # make
../build/release/ponyc  stable -o build/release
Building builtin -> /ponyc/packages/builtin
Building stable -> /ponyc/pony-stable/stable
Building files -> /ponyc/packages/files
Building time -> /ponyc/packages/time
Building collections -> /ponyc/packages/collections
Building ponytest -> /ponyc/packages/ponytest
Building random -> /ponyc/packages/random
Building buffered -> /ponyc/packages/buffered
Building term -> /ponyc/packages/term
Building promises -> /ponyc/packages/promises
Building strings -> /ponyc/packages/strings
Building signals -> /ponyc/packages/signals
Building capsicum -> /ponyc/packages/capsicum
Building json -> /ponyc/packages/json
Building format -> /ponyc/packages/format
Building options -> /ponyc/packages/options
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Writing build/release/stable.o
Linking build/release/stable
/ponyc/pony-stable # ../build/release/ponyc --version
0.28.1-9213b98b [release]
compiled with: llvm 7.1.0 -- cc (Alpine 8.3.0) 8.3.0
Defaults: pic=true ssl=openssl_0.9.0
Cogitri commented 5 years ago

I installed llvm 7 instead of llvm 6 because alpine 3.10 doesn't have pre-built packages for llvm 6.

Yup, llvm6 is in the testing repo for now (like ponyc). I guess I'll try with LLVM7 now that 7.1.0 works better with musl.

I tried the same steps, but it still errors out for me :thinking:

 ~/D/ponyc-0.28.1> sudo env LLVM_CONFIG=/usr/bin/llvm7-config default_pic=true make install
ponyc -v
0.28.1 [release]
compiled with: llvm 7.1.0 -- cc (Alpine 8.3.0) 8.3.0
Defaults: pic=true ssl=openssl_0.9.0
~/D/pony-stable-0.2.0> make
sed s/%%VERSION%%/"0.2.0 [release]"/ stable/version.pony.in > stable/version.pony
mkdir -p build/release
ponyc  stable -o build/release
Building builtin -> /usr/lib/pony/0.28.1/packages/builtin
Building stable -> /home/rasmus/Downloads/pony-stable-0.2.0/stable
Building files -> /usr/lib/pony/0.28.1/packages/files
Building time -> /usr/lib/pony/0.28.1/packages/time
Building collections -> /usr/lib/pony/0.28.1/packages/collections
Building ponytest -> /usr/lib/pony/0.28.1/packages/ponytest
Building random -> /usr/lib/pony/0.28.1/packages/random
Building buffered -> /usr/lib/pony/0.28.1/packages/buffered
Building term -> /usr/lib/pony/0.28.1/packages/term
Building promises -> /usr/lib/pony/0.28.1/packages/promises
Building strings -> /usr/lib/pony/0.28.1/packages/strings
Building signals -> /usr/lib/pony/0.28.1/packages/signals
Building capsicum -> /usr/lib/pony/0.28.1/packages/capsicum
Building json -> /usr/lib/pony/0.28.1/packages/json
Building format -> /usr/lib/pony/0.28.1/packages/format
Building options -> /usr/lib/pony/0.28.1/packages/options
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Writing build/release/stable.o
Linking build/release/stable
/usr/lib/gcc/x86_64-alpine-linux-musl/8.3.0/../../../../x86_64-alpine-linux-musl/bin/ld.gold: fatal error: build/release/stable: No error information
collect2: error: ld returned 1 exit status
Warning: environment variable $CC undefined, using gcc as the linker
Error:
unable to link: gcc -o build/release/stable -O3 -march=native -mcx16 -latomic  -fuse-ld=gold build/release/stable.o -L"/usr/lib/pony/0.28.1/bin/" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/" -L"/usr/lib/pony/0.28.1/bin/../lib/native" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../lib/native" -L"/usr/lib/pony/0.28.1/bin/../packages" -Wl,-rpath,"/usr/lib/pony/0.28.1/bin/../packages" -L"/usr/local/lib" -Wl,-rpath,"/usr/local/lib" -Wl,--start-group -l"rt" -Wl,--end-group  -lpthread  -lponyrt-pic -ldl -lm -lexecinfo 
make: *** [Makefile:43: build/release/stable] Error 255
dipinhora commented 5 years ago

@Cogitri to make sure I understand, did you try in a clean docker container like I did or in your existing environment or some other configuration/environment?

It would be extremely helpful if you're able to provide instructions on how to reproduce the issue in either a docker container or a VM starting from a clean/base Alpine 3.10 install.

Cogitri commented 5 years ago

I tested this both in a clean environment via Docker and in my own system. I built ponyc manually on my system and via abuild in Docker (which is Alpine's package format). To build it with abuild:

git clone https://github.com/alpinelinux/docker-abuild git clone https://github.com/Cogitri/aports -b ponyc cd docker-abuild && make cd ../aports && cd testing/pony-stable && ../../../docker-abuild/dabuild -r

Docker-abuild should automatically pull a clean alpine container from dockerhub, containing only the alpine base and a few build tools. This should build pony-stable with the ponyc currently in our repos, you can do dabuild -r in aports/testing/ponyc to build ponyc.

dipinhora commented 5 years ago

@Cogitri I ran the commands you provided and did not encounter any errors. In case it matters, I ran the commands in a Virtualbox VM of Ubuntu Bionic on Windows 10 on x86_64.

vagrant@ubuntu-bionic:~/aports/testing/pony-stable$ sudo ../../../docker-abuild/dabuild -r
Unable to find image 'alpinelinux/docker-abuild:edge-x86_64' locally
edge-x86_64: Pulling from alpinelinux/docker-abuild
2004ee2154b4: Pull complete
394498201e0f: Pull complete
78aa2f98ce2b: Pull complete
ab5b5d86f594: Pull complete
17eb0a500025: Pull complete
b196ba2d604c: Pull complete
Digest: sha256:3bf92939a037bd7b822e72c6cf6a5b32bb08bd2ce5b54ebb09f2d98811e4c73e
Status: Downloaded newer image for alpinelinux/docker-abuild:edge-x86_64
Generating RSA private key, 2048 bit long modulus (2 primes)
....................................+++++
...............+++++
e is 65537 (0x010001)
writing RSA key
>>>
>>> You'll need to install /home/builder/.abuild/-5d1a7ec6.rsa.pub into
>>> /etc/apk/keys to be able to install packages and repositories signed with
>>> /home/builder/.abuild/-5d1a7ec6.rsa
>>>
>>> Please remember to make a safe backup of your private key:
>>> /home/builder/.abuild/-5d1a7ec6.rsa
>>>
'/home/builder/.abuild/-5d1a7ec6.rsa.pub' -> '/etc/apk/keys/-5d1a7ec6.rsa.pub'
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
WARNING: Ignoring /home/builder/packages/main/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: Ignoring /home/builder/packages/community/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: Ignoring /home/builder/packages/testing/x86_64/APKINDEX.tar.gz: UNTRUSTED signature
(1/4) Upgrading scanelf (1.2.3-r0 -> 1.2.4-r0)
(2/4) Upgrading pax-utils (1.2.3-r0 -> 1.2.4-r0)
(3/4) Upgrading nghttp2-libs (1.38.0-r0 -> 1.39.1-r0)
(4/4) Upgrading expat (2.2.6-r0 -> 2.2.7-r0)
Executing busybox-1.30.1-r2.trigger
OK: 185 MiB in 54 packages
>>> pony-stable: Building testing/pony-stable 0.2.0-r0 (using abuild 3.4.0-r0) started Mon, 01 Jul 2019 21:44:39 +0000
>>> pony-stable: Checking sanity of /home/builder/aports/testing/pony-stable/APKBUILD...
>>> pony-stable: Analyzing dependencies...
>>> pony-stable: Installing for build: build-base ponyc libexecinfo-dev
WARNING: Ignoring /home/builder/packages//testing/x86_64/APKINDEX.tar.gz: UNTRUSTED signature
WARNING: Ignoring /home/builder/packages/main/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: Ignoring /home/builder/packages/community/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: Ignoring /home/builder/packages/testing/x86_64/APKINDEX.tar.gz: UNTRUSTED signature
(1/7) Installing binutils-gold (2.32-r0)
(2/7) Installing libffi (3.2.1-r6)
(3/7) Installing llvm6-libs (6.0.1-r3)
(4/7) Installing libexecinfo (1.1-r1)
(5/7) Installing ponyc (0.28.1-r0)
(6/7) Installing libexecinfo-dev (1.1-r1)
(7/7) Installing .makedepends-pony-stable (20190701.214440)
Executing busybox-1.30.1-r2.trigger
OK: 234 MiB in 61 packages
>>> pony-stable: Cleaning up srcdir
>>> pony-stable: Cleaning up pkgdir
>>> pony-stable: Fetching pony-stable-0.2.0.tar.gz::https://github.com/ponylang/pony-stable/archive/0.2.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   127    0   127    0     0    679      0 --:--:-- --:--:-- --:--:--   675
100 51726    0 51726    0     0   119k      0 --:--:-- --:--:-- --:--:--  119k
>>> pony-stable: Fetching pony-stable-0.2.0.tar.gz::https://github.com/ponylang/pony-stable/archive/0.2.0.tar.gz
>>> pony-stable: Checking sha512sums...
pony-stable-0.2.0.tar.gz: OK
>>> pony-stable: Unpacking /var/cache/distfiles/pony-stable-0.2.0.tar.gz...
sed s/%%VERSION%%/"0.2.0 [release]"/ stable/version.pony.in > stable/version.pony
mkdir -p build/release
ponyc  stable -o build/release
Building builtin -> /usr/lib/pony/0.28.1/packages/builtin
Building stable -> /home/builder/aports/testing/pony-stable/src/pony-stable-0.2.0/stable
Building files -> /usr/lib/pony/0.28.1/packages/files
Building time -> /usr/lib/pony/0.28.1/packages/time
Building collections -> /usr/lib/pony/0.28.1/packages/collections
Building ponytest -> /usr/lib/pony/0.28.1/packages/ponytest
Building random -> /usr/lib/pony/0.28.1/packages/random
Building buffered -> /usr/lib/pony/0.28.1/packages/buffered
Building term -> /usr/lib/pony/0.28.1/packages/term
Building promises -> /usr/lib/pony/0.28.1/packages/promises
Building strings -> /usr/lib/pony/0.28.1/packages/strings
Building signals -> /usr/lib/pony/0.28.1/packages/signals
Building capsicum -> /usr/lib/pony/0.28.1/packages/capsicum
Building json -> /usr/lib/pony/0.28.1/packages/json
Building format -> /usr/lib/pony/0.28.1/packages/format
Building options -> /usr/lib/pony/0.28.1/packages/options
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Writing build/release/stable.o
Linking build/release/stable
make: *** No rule to make target 'check'.  Stop.
>>> ERROR: pony-stable: check failed
>>> pony-stable: Uninstalling dependencies...
WARNING: Ignoring /home/builder/packages/main/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: Ignoring /home/builder/packages/community/x86_64/APKINDEX.tar.gz: No such file or directory
WARNING: Ignoring /home/builder/packages/testing/x86_64/APKINDEX.tar.gz: UNTRUSTED signature
(1/7) Purging .makedepends-pony-stable (20190701.214440)
(2/7) Purging ponyc (0.28.1-r0)
(3/7) Purging binutils-gold (2.32-r0)
(4/7) Purging libexecinfo-dev (1.1-r1)
(5/7) Purging libexecinfo (1.1-r1)
(6/7) Purging llvm6-libs (6.0.1-r3)
(7/7) Purging libffi (3.2.1-r6)
Executing busybox-1.30.1-r2.trigger
OK: 185 MiB in 54 packages
vagrant@ubuntu-bionic:~/aports/testing/pony-stable$
Cogitri commented 5 years ago

Hm, no, that shouldn't matter, but that's super weird :o

I guess I'll closes this for now then and see if I can get this working somehow