ocaml / opam-repository

Main public package repository for opam, the source package manager of OCaml.
https://opam.ocaml.org
Creative Commons Zero v1.0 Universal
518 stars 1.13k forks source link

Failed compilation of ocaml-secondary-compiler during utop installation in new machine at ocaml-base-compiler.4.07.0 #18586

Closed yonoteam closed 3 years ago

yonoteam commented 3 years ago

Hello, my computer suggested filing a bug report and I found nothing related in previous issues. Below I enumerate the process that generated the error message appearing below. Any help/explanation is welcomed.

Using opam config report after step 14 below, outputs the following message.

    # opam config report
    # opam-version      2.0.8 
    # self-upgrade      no
    # system            arch=arm64 os=macos os-distribution=homebrew os-version=11.2.3
    # solver            builtin-mccs+glpk
    # install-criteria  -removed,-count[version-lag,request],-count[version-lag,changed],-changed
    # upgrade-criteria  -removed,-count[version-lag,solution],-new
    # jobs              7
    # repositories      1 (http) (default repo at 5e01cfa3)
    # pinned            0
    # current-switch    ocaml-base-compiler.4.07.0

Process:

  1. opam switch list reports I am using ocaml-base-compiler.4.07.0
  2. did eval $(opam env)
  3. did opam init
  4. did opam install zarith
  5. tried opam install graphics but failed, reported missing xorgproto and xquartz
  6. did opam install ocamlbuild
  7. did opam install ocamlfind
  8. retried opam install graphics but failed again for same reason
  9. brew installed xorgproto and xquartz
  10. retried opam install graphics and worked
  11. did opam install zarith
  12. did opam install utop but error message appeared suggesting filing a bug report here, trying installing again sequentially or restore to former state with suggested command.
  13. restored to former state with suggested command
  14. retried opam install utop but failed again suggesting same fixes
  15. tried opam install --jobs=1 utop but failed with following message appearing so decided to file bug-report:

    The following actions will be performed:
      - install ocaml-secondary-compiler 4.08.1-1 [required by ocamlfind-secondary]
      - install ocamlfind-secondary      1.8.1    [required by dune]
      - install dune                     2.8.5    [required by utop]
      - install trie                     1.0.0    [required by mew]
      - install result                   1.5      [required by lwt]
      - install ocaml-syntax-shims       1.0.0    [required by lwt]
      - install mmap                     1.1.0    [required by lwt]
      - install csexp                    1.5.1    [required by dune-configurator]
      - install cppo                     1.6.7    [required by utop]
      - install camomile                 1.0.2    [required by utop]
      - install mew                      0.1.0    [required by mew_vi]
      - install dune-configurator        2.8.5    [required by lwt]
      - install ocplib-endian            1.1      [required by lwt]
      - install charInfo_width           1.1.0    [required by zed]
      - install mew_vi                   0.5.0    [required by lambda-term]
      - install lwt                      5.4.0    [required by utop]
      - install zed                      3.1.0    [required by lambda-term]
      - install lwt_react                1.1.4    [required by utop]
      - install lwt_log                  1.1.1    [required by lambda-term]
      - install lambda-term              3.1.0    [required by utop]
      - install utop                     2.7.0
    ===== 21 to install =====
    Do you want to continue? [Y/n] Y
    
    <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    [camomile.1.0.2] found in cache
    [charInfo_width.1.1.0] found in cache
    [cppo.1.6.7] found in cache
    [csexp.1.5.1] found in cache
    [dune.2.8.5] found in cache
    [dune-configurator.2.8.5] found in cache
    [lambda-term.3.1.0] found in cache
    [lwt.5.4.0] found in cache
    [lwt_log.1.1.1] found in cache
    [lwt_react.1.1.4] found in cache
    [mew.0.1.0] found in cache
    [mew_vi.0.5.0] found in cache
    [mmap.1.1.0] found in cache
    [ocaml-secondary-compiler.4.08.1-1] found in cache
    [ocaml-syntax-shims.1.0.0] found in cache
    [ocamlfind-secondary.1.8.1] found in cache
    [ocplib-endian.1.1] found in cache
    [result.1.5] found in cache
    [trie.1.0.0] found in cache
    [utop.2.7.0] found in cache
    [zed.3.1.0] found in cache
    
    <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    [ERROR] The compilation of ocaml-secondary-compiler failed at "/Users/pzx681/.opam/opam-init/hooks/sandbox.sh build make -j1 world.opt".
    
    #=== ERROR while compiling ocaml-secondary-compiler.4.08.1-1 ==================#
    # context     2.0.8 | macos/arm64 | ocaml-base-compiler.4.07.0 | https://opam.ocaml.org#5e01cfa3
    # path        ~/.opam/ocaml-base-compiler.4.07.0/.opam-switch/build/ocaml-secondary-compiler.4.08.1-1
    # command     ~/.opam/opam-init/hooks/sandbox.sh build make -j1 world.opt
    # exit-code   2
    # env-file    ~/.opam/log/ocaml-secondary-compiler-24170-42ef32.env
    # output-file ~/.opam/log/ocaml-secondary-compiler-24170-42ef32.out
    ### output ###
    # roots_nat.c:470:19: error: implicit declaration of function 'Saved_return_address' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    # [...]
    # roots_nat.c:477:46: error: implicit declaration of function 'Callback_link' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    #         struct caml_context * next_context = Callback_link(sp);
    #                                              ^
    # roots_nat.c:477:31: warning: incompatible integer to pointer conversion initializing 'struct caml_context *' with an expression of type 'int' [-Wint-conversion]
    #         struct caml_context * next_context = Callback_link(sp);
    #                               ^              ~~~~~~~~~~~~~~~~~
    # 2 warnings and 4 errors generated.
    # make[3]: *** [roots_nat_n.o] Error 1
    # make[2]: *** [makeruntimeopt] Error 2
    # make[1]: *** [opt.opt] Error 2
    # make: *** [world.opt] Error 2
    
    <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
    +- The following actions failed
    | - build ocaml-secondary-compiler 4.08.1-1
    +- 
    - No changes have been performed
kit-ty-kate commented 3 years ago

Hi, I reformatted your issue for more clarity. Please don't forget to use the proper markdown characters when pasting logs.

I'm a bit confused at your test machine. Is that really an macOS/arm64 (M1)? If so how did you manage to install OCaml 4.07 on it? Are you running it using Rosetta2?

Currently it should not be possible to compile any OCaml compiler other than 4.10.2 or >= 4.12.0, thus my confusion ^^" Furthermore the log indicates that your opam-repository is up-to-date so there shouldn't be any issue. ocaml-base-compiler.4.07.0 explicitly proscribe macOS/arm64: https://github.com/ocaml/opam-repository/blob/5e01cfa3986cc55bd97d8aac265343be6616315f/packages/ocaml-base-compiler/ocaml-base-compiler.4.07.0/opam#L52

yonoteam commented 3 years ago

Hi, I reformatted your issue for more clarity. Please don't forget to use the proper markdown characters when pasting logs.

Hello, thanks. Yes, I was about to correct it and you beat me to it.

I'm a bit confused at your test machine. Is that really an macOS/arm64 (M1)? If so how did you manage to install OCaml 4.07 on it? Are you running it using Rosetta2?

Yes it is a macOS/arm64 (M1). I cheated by having the Isabelle proof assistant do it for me. I do not know how it does so (they do mention Rosetta2 in their news file for the 2021 version), but by using isabelle ocaml_setup I got ocaml 4.07.

Currently it should not be possible to compile any OCaml compiler other than 4.10.2 or >= 4.12.0, thus my confusion ^^" Furthermore the log indicates that your opam-repository is up-to-date so there shouldn't be any issue. ocaml-base-compiler.4.07.0 explicitly proscribe macOS/arm64:

Then, is that the solution? Use an older model of computer or the version of OCaml incompatible with Isabelle?

avsm commented 3 years ago

Install Intel Homebrew (in /usr/local) so you have an x86_64 toolchain on the M1, and then proceed with the Isabelle installation using that. You need your whole toolchain to be translated if you want to remain x86 compatible. And perhaps put a feature request to Isabelle to upgrade their supported version of the OCaml compiler to a more recent one.

kit-ty-kate commented 3 years ago

I would advise against using isabelle ocaml_setup as it seems very unsafe (for instance, they purposefully disable sandboxing for some reason): https://isabelle-dev.sketis.net/source/isabelle/browse/default/lib/Tools/ocaml_setup$18

Then, is that the solution? Use an older model of computer or the version of OCaml incompatible with Isabelle?

Unless you're trying to do something with the opam switch created by Isabelle, the solution is rather simple: Creating a new switch with a compatible/newer OCaml compiler

opam switch create 4.12.0

The underlying issue you encountered will be fixed by https://github.com/ocaml/opam-repository/pull/18587, though this should not have been possible to encounter in the first place and is very much an edge-case.

yonoteam commented 3 years ago

Install Intel Homebrew (in /usr/local) so you have an x86_64 toolchain on the M1, and then proceed with the Isabelle installation using that. You need your whole toolchain to be translated if you want to remain x86 compatible. And perhaps put a feature request to Isabelle to upgrade their supported version of the OCaml compiler to a more recent one.

Thanks for the suggestions. I'll have a go at them.

I would advise against using isabelle ocaml_setup as it seems very unsafe (for instance, they purposefully disable sandboxing for some reason): https://isabelle-dev.sketis.net/source/isabelle/browse/default/lib/Tools/ocaml_setup$18

Thanks for the advice, I have pointed to this issue in the Isabelle mailing list.

The underlying issue you encountered will be fixed by #18587, though this should not have been possible to encounter in the first place and is very much an edge-case.

Thanks for the help.