crystal-lang / distribution-scripts

40 stars 24 forks source link

Sometimes packages are built without static linking #33

Closed bcardiff closed 5 years ago

bcardiff commented 5 years ago

0.28.0 32 bits .deb packages went out without static linking.

Yet nightlies worked fine https://circleci.com/gh/crystal-lang/crystal/21793#artifacts/containers/0

The tagged one are not statically linked https://circleci.com/gh/crystal-lang/crystal/21811#artifacts/containers/0

The non-static link also happened in maintenance release ci/preview.

But since last nightlies, before 0.28 worked I thought tagged version would work.

bcardiff commented 5 years ago

In the https://circleci.com/gh/crystal-lang/crystal/23243 I included a ldd output that shows the compiler is not statically linked.

Step 42/43 : RUN ldd /crystal-${crystal_version}-${package_iteration}/lib/crystal/bin/crystal
 ---> Running in cfb289fa3e04
    /lib/ld-musl-x86_64.so.1 (0x7fe912afa000)
    libLLVM-4.0.so => /usr/lib/libLLVM-4.0.so (0x7fe90e879000)
    libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7fe90e526000)
    libpcre.so.1 => /usr/lib/libpcre.so.1 (0x7fe90e2cb000)
    libevent-2.1.so.6 => /usr/lib/libevent-2.1.so.6 (0x7fe90e081000)
    libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7fe90de6f000)
    libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7fe912afa000)
    libffi.so.6 => /usr/lib/libffi.so.6 (0x7fe90dc67000)
    libz.so.1 => /lib/libz.so.1 (0x7fe90da50000)
 ---> 56f0404e09f0
Removing intermediate container cfb289fa3e04
Step 43/43 : RUN ldd /crystal-${crystal_version}-${package_iteration}/lib/crystal/bin/shards
 ---> Running in 34bc5b40004c
    ldd (0x7f9a47082000)
bcardiff commented 5 years ago

In the https://circleci.com/gh/crystal-lang/crystal/23330 the output is

Removing intermediate container 4758144cff46
Step 42/43 : RUN ldd /crystal-${crystal_version}-${package_iteration}/lib/crystal/bin/crystal
 ---> Running in 91564462ee25
    ldd (0x7fb66a066000)
 ---> e76da357088f
Removing intermediate container 91564462ee25
Step 43/43 : RUN ldd /crystal-${crystal_version}-${package_iteration}/lib/crystal/bin/shards
 ---> Running in 24adcc5859c8
    ldd (0x7f2fb3768000)

The same docker image for alpine and debian were used (the same sha256 was reported).

bcardiff commented 5 years ago

@RX14 do you have any clue what can be happening here?

bcardiff commented 5 years ago

It seems that the issue is in the make crystal stats=true static=true command in the alpine container.

In faulty builds the binary that is included in the package is the one generated by

$ cc '/crystal-musl.o' -o '.build/crystal' -rdynamic src/llvm/ext/llvm_ext.o ...

And later the make crystal stats=true static=true is failing with a make: crystal: Command not found. It's odd that the error (probably triggered in the) bash wrapper didn't make make fail to make the docker build command fail.

Step 33/43 : RUN git clone https://github.com/crystal-lang/crystal  && cd crystal  && git checkout ${crystal_sha1}   && make deps  && mkdir .build  && cc '/crystal-musl.o' -o '.build/crystal' -rdynamic src/llvm/ext/llvm_ext.o `llvm-config --libs --system-libs --ldflags` -lstdc++ -lpcre -lm -lgc -lpthread src/ext/libcrystal.a -levent -lrt   && touch src/compiler/crystal.cr  && make crystal stats=true static=true ${release:+release=true}                  CRYSTAL_CONFIG_TARGET=${gnu_target}
 ---> Running in 0c0979847364
Cloning into 'crystal'...
Note: checking out '0f48ec73278f8ff9d9f2e3053d2556539f3cd8a8'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 0f48ec732 Update distribution-scripts
make: crystal: Command not found
Using /usr/lib/llvm4/bin/llvm-config [version=4.0.0]
g++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc -I/usr/lib/llvm4/include -Os -fomit-frame-pointer -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++1y -ffunction-sections -fdata-sections -O3 -DNDEBUG  -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
cc -fPIC -pipe -O2 -fPIC    -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
make: crystal: Command not found
Using /usr/lib/llvm4/bin/llvm-config [version=4.0.0]
make: Nothing to be done for 'crystal'.
straight-shoota commented 5 years ago

Can we close this, assuming #37 was all that needed to be fixed?