crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.45k stars 1.62k forks source link

Can't build Crystal after building Crystal #2195

Closed stugol closed 8 years ago

stugol commented 8 years ago

This is very strange.

I've set up a fresh Debian system, installed everything necessary to build Crystal, and built Crystal.

I now cannot build Crystal again. I get errors about GC_set_handle_fork, despite the fact that I must, by definition, have the correct GC on my system.

# make
CRYSTAL_CONFIG_PATH=`pwd`/src ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr
Using compiled compiler at .build/crystal
/home/infinity/crystal/.crystal/crystal-run-macro-run-_opt_crystal_src_ecr_process.cr.tmp: symbol lookup error: /home/infinity/crystal/.crystal/crystal-run-macro-run-_opt_crystal_src_ecr_process.cr.tmp: undefined symbol: GC_set_handle_fork
Error in ./src/compiler/crystal.cr:3: instantiating 'Crystal::Command:Class#run()'

Crystal::Command.run
                 ^~~

instantiating 'run(Array(String))'

in ./src/compiler/crystal/command.cr:42: instantiating 'Crystal::Command#run()'

    new(options).run
                 ^~~

in ./src/compiler/crystal/command.cr:58: instantiating 'init()'

        init
        ^~~~

in ./src/compiler/crystal/command.cr:146: instantiating 'Crystal::Init:Module#run(Array(String))'

    Init.run(options)
         ^~~

in ./src/compiler/crystal/tools/init.cr:41: instantiating 'Crystal::Init::InitProject#run()'

      InitProject.new(config).run
                              ^~~

in ./src/compiler/crystal/tools/init.cr:149: instantiating 'Array(Crystal::Init::View+:Class)#each()'

        views.each do |view|
              ^~~~

in /opt/crystal/src/array.cr:776: instantiating 'each_index()'

    each_index do |i|
    ^~~~~~~~~~

in /opt/crystal/src/array.cr:776: instantiating 'each_index()'

    each_index do |i|
    ^~~~~~~~~~

in ./src/compiler/crystal/tools/init.cr:149: instantiating 'Array(Crystal::Init::View+:Class)#each()'

        views.each do |view|
              ^~~~

in ./src/compiler/crystal/tools/init.cr:150: instantiating 'Crystal::Init::View+#render()'

          view.new(config).render
                           ^~~~~~

in ./src/compiler/crystal/tools/init.cr:127: instantiating 'to_s()'

        File.write(full_path, to_s)
                              ^~~~

in /opt/crystal/src/object.cr:78: instantiating 'String:Class#build()'

    String.build do |io|
           ^~~~~

in /opt/crystal/src/string.cr:238: instantiating 'String::Builder:Class#build(Int32)'

    String::Builder.build(capacity) do |builder|
                    ^~~~~

in /opt/crystal/src/string.cr:238: instantiating 'String::Builder:Class#build(Int32)'

    String::Builder.build(capacity) do |builder|
                    ^~~~~

in /opt/crystal/src/object.cr:78: instantiating 'String:Class#build()'

    String.build do |io|
           ^~~~~

in /opt/crystal/src/object.cr:79: instantiating 'to_s(String::Builder)'

      to_s io
      ^~~~

in macro 'embed' /opt/crystal/src/ecr/macros.cr:81, line 1:

  1.     {{ run("ecr/process", "/home/infinity/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__") }}
  2.

    {{ run("ecr/process", "/home/infinity/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__") }}
    ^

expanding macro
in macro 'embed' /opt/crystal/src/ecr/macros.cr:81, line 1:

  1.     {{ run("ecr/process", "/home/infinity/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__") }}
  2.

    {{ run("ecr/process", "/home/infinity/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__") }}
       ^~~

Error executing run: ecr/process "/home/infinity/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr" "__io__"

Got:

make: *** [.build/crystal] Error 1

In other words, the freshly built Crystal works and can build other Crystal programs; but cannot build itself!

jhass commented 8 years ago

Ping, can you still reproduce? Did you verify you have all the libraries from https://github.com/crystal-lang/crystal/wiki/All-required-libraries installed? In their most recent version?

asterite commented 8 years ago

I'm closing this. Crystal is being built in several places without problem. For contributing to Crystal one could also use the vagrant or docker images.

xxuejie commented 7 years ago

I'm running this problem as well. In order to reproduce this, I created a Dockerfile containing a fresh Ubuntu instance and installed all the dependencies according to the doc: https://gist.github.com/xxuejie/5f77dd5bd81286adbdd6c4aa1d3445b8

To reproduce this, feel free to follow the following steps:

First, we make sure put the Dockerfile and crystal repo in the same directory:

$ ls
Dockerfile crystal

Then we build the docker image:

$ docker build .
Sending build context to Docker daemon  47.95MB
Step 1/10 : FROM ubuntu:xenial
 ---> f49eec89601e
Step 2/10 : RUN apt-get update
 ---> Using cache
 ---> c7cc7a41198f
Step 3/10 : RUN apt-get install   libbsd-dev   libedit-dev   libevent-core-2.0-5   libevent-dev   libevent-extra-2.0-5   libevent-openssl-2.0-5   libevent-pthreads-2.0-5   libgmp-dev   libgmpxx4ldbl   libssl-dev   libxml2-dev   libyaml-dev   libreadline-dev   automake   libtool   git   llvm   libpcre3-dev   build-essential -y
 ---> Using cache
 ---> 46a7b245cf20
Step 4/10 : RUN apt-get install -y curl apt-transport-https
 ---> Using cache
 ---> 678bd6566182
Step 5/10 : RUN curl https://dist.crystal-lang.org/apt/setup.sh | bash
 ---> Using cache
 ---> 75b498e718ee
Step 6/10 : RUN apt-get install -y crystal
 ---> Using cache
 ---> 1f9c397ff522
Step 7/10 : RUN apt-get install -y pkg-config
 ---> Using cache
 ---> a45e03d3fd75
Step 8/10 : RUN git clone https://github.com/ivmai/bdwgc.git /bdwgc
 ---> Using cache
 ---> 53da67e573ca
Step 9/10 : RUN git clone https://github.com/ivmai/libatomic_ops.git /bdwgc/libatomic_ops
 ---> Using cache
 ---> 467c80bc0b23
Step 10/10 : RUN cd /bdwgc && autoreconf -vif && automake --add-missing && ./configure && make && make check && make install
 ---> Using cache
 ---> 79f8c8174d24
Successfully built 79f8c8174d24

Now we run the docker image with crystal source attached, and build crystal:

$ docker run --rm -it -v $(pwd)/crystal:/crystal 79f8c8174d24 bash
root@1fd7f491665b:/# cd /crystal/
root@1fd7f491665b:/crystal# ls
BACKERS.md    CODE_OF_CONDUCT.md  Dockerfile          ISSUE_TEMPLATE.md  Makefile   Vagrantfile  circle.yml  man      scripts  src
CHANGELOG.md  CONTRIBUTING.md     Dockerfile.release  LICENSE            README.md  bin          etc         samples  spec
root@1fd7f491665b:/crystal# make
Using /usr/bin/llvm-config-3.8 [version=3.8.0]
g++ -c  -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc `/usr/bin/llvm-config-3.8 --cxxflags`
cc -fPIC    -c -o src/ext/sigfault.o src/ext/sigfault.c
ar -rcs src/ext/libcrystal.a src/ext/sigfault.o
CRYSTAL_CONFIG_PATH=`pwd`/src ./bin/crystal build  -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib
Error in src/compiler/crystal.cr:8: instantiating 'Crystal::Command:Class#run()'

Crystal::Command.run
                 ^~~

in src/compiler/crystal/command.cr:48: instantiating 'run(Array(String))'

  def self.run(options = ARGV)
  ^

in src/compiler/crystal/command.cr:49: instantiating 'Crystal::Command#run()'

    new(options).run
                 ^~~

in src/compiler/crystal/command.cr:66: instantiating 'init()'

        init
        ^~~~

in src/compiler/crystal/command.cr:170: instantiating 'Crystal::Init:Module#run(Array(String))'

    Init.run(options)
         ^~~

in src/compiler/crystal/tools/init.cr:43: instantiating 'Crystal::Init::InitProject#run()'

      InitProject.new(config).run
                              ^~~

in src/compiler/crystal/tools/init.cr:155: instantiating 'Array(Crystal::Init::View:Class)#each()'

        views.each do |view|
              ^~~~

in src/indexable.cr:148: instantiating 'each_index()'

    each_index do |i|
    ^~~~~~~~~~

in src/indexable.cr:148: instantiating 'each_index()'

    each_index do |i|
    ^~~~~~~~~~

in src/compiler/crystal/tools/init.cr:155: instantiating 'Array(Crystal::Init::View:Class)#each()'

        views.each do |view|
              ^~~~

in src/compiler/crystal/tools/init.cr:156: instantiating 'Crystal::Init::View+#render()'

          view.new(config).render
                           ^~~~~~

in src/compiler/crystal/tools/init.cr:133: instantiating 'to_s()'

        File.write(full_path, to_s)
                              ^~~~

in src/object.cr:75: instantiating 'String:Class#build()'

    String.build do |io|
           ^~~~~

in src/string.cr:269: instantiating 'String::Builder:Class#build(Int32)'

    String::Builder.build(capacity) do |builder|
                    ^~~~~

in src/string.cr:269: instantiating 'String::Builder:Class#build(Int32)'

    String::Builder.build(capacity) do |builder|
                    ^~~~~

in src/object.cr:75: instantiating 'String:Class#build()'

    String.build do |io|
           ^~~~~

in src/object.cr:76: instantiating 'to_s(String::Builder)'

      to_s io
      ^~~~

in macro 'def_to_s' /crystal/src/ecr/macros.cr:35, line 2:

   1.     def to_s(__io__)
>  2.       ECR.embed "/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__"
   3.     end
   4.

expanding macro
in macro 'embed' /crystal/src/ecr/macros.cr:69, line 1:

>  1.     {{ run("ecr/process", "/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__") }}
   2.

expanding macro
in macro 'def_to_s' /crystal/src/ecr/macros.cr:35, line 2:

   1.     def to_s(__io__)
>  2.       ECR.embed "/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__"
   3.     end
   4.

expanding macro
in macro 'embed' /crystal/src/ecr/macros.cr:69, line 1:

>  1.     {{ run("ecr/process", "/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr", "__io__") }}
   2.

Error executing run: ecr/process "/crystal/src/compiler/crystal/tools/init/template/example_spec.cr.ecr" "__io__"

Got:

Makefile:116: recipe for target '.build/crystal' failed
make: *** [.build/crystal] Error 1

And the same error in this issue happened.

Any chance you guys can take a look at this problem? Thanks for the help!

xxuejie commented 7 years ago

After some tries I can get this to work, the solution is to install libgc-dev package, then make and make spec will work. So maybe the problem is steps used to install boehm GC here: https://github.com/crystal-lang/crystal/wiki/All-required-libraries#general?

RX14 commented 7 years ago

My hunch is that the built ecr/process is segfaulting, probably in the synamic linker. We don't see the error because stderr isn't captured (did we merge a PR which fixed this recently? not merged: https://github.com/crystal-lang/crystal/pull/4614)

ysbaddaden commented 7 years ago

Maybe we have an incompatibility with boehm-gc (master)? We support/require v7.6 which can be installed. Weirdly enough Ubuntu Xenial only provides 7.4, so it should fail when installing gc-dev.

da99 commented 6 years ago

I received the same error today after updating the packages in my OS. I was able to compile once again by removing the cache (default location: $HOME/.crystal).