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

[new release] crlibm (0.5) #19943

Merged
merged 2 commits into from Nov 9, 2021
Merged

Conversation

Chris00
Copy link
Member

@Chris00 Chris00 commented Nov 3, 2021

Binding to CRlibm, a correctly rounded math lib

CHANGES:
  • Rename sub-modules to more standard names.

@Chris00
Copy link
Member Author

Chris00 commented Nov 3, 2021

Not sure what the problem is — it builds fine on my machine and by Github Actions.

@mseri
Copy link
Member

mseri commented Nov 4, 2021

Looks like some kind of corruption in the Ci? Can it be?

@kit-ty-kate
Copy link
Member

The package failed to build on x86_32:

#=== ERROR while compiling crlibm.0.5 =========================================#
# context              2.1.0 | linux/x86_32 | ocaml-base-compiler.4.13.1 | pinned(https://github.com/Chris00/ocaml-crlibm/releases/download/0.5/crlibm-0.5.tbz)
# path                 ~/.opam/4.13/.opam-switch/build/crlibm.0.5
# command              ~/.opam/opam-init/hooks/sandbox.sh build dune build -p crlibm -j 31 @runtest
# exit-code            1
# env-file             ~/.opam/log/crlibm-77-28f843.env
# output-file          ~/.opam/log/crlibm-77-28f843.out
### output ###
#     ocamlopt tests/test.exe (exit 2)
# (cd _build/default && /home/opam/.opam/4.13/bin/ocamlopt.opt -w -40 -g -o tests/test.exe src/crlibm.cmxa -I src /home/opam/.opam/4.13/lib/ocaml/unix.cmxa -I /home/opam/.opam/4.13/lib/ocaml /home/opam/.opam/4.13/lib/benchmark/benchmark.cmxa tests/.test.eobjs/native/test.cmx)
# /usr/bin/ld: tests/.test.eobjs/native/test.o: warning: relocation in read-only section `.text'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_346':
# :(.text+0x5c): undefined reference to `log10_rn'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_348':
# :(.text+0xac): undefined reference to `log2_rn'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_426':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm.ml:67: undefined reference to `log10_rd'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_424':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm.ml:67: undefined reference to `log2_rd'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_466':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm.ml:107: undefined reference to `log10_ru'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_464':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm.ml:107: undefined reference to `log2_ru'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_506':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm.ml:147: undefined reference to `log10_rz'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__fun_504':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm.ml:147: undefined reference to `log2_rz'
# /usr/bin/ld: src/crlibm.a(crlibm.o): in function `camlCrlibm__1':
# :(.data+0x464): undefined reference to `log10_rz'
# /usr/bin/ld: :(.data+0x468): undefined reference to `log2_rz'
# /usr/bin/ld: :(.data+0x4b4): undefined reference to `log10_ru'
# /usr/bin/ld: :(.data+0x4b8): undefined reference to `log2_ru'
# /usr/bin/ld: :(.data+0x504): undefined reference to `log10_rd'
# /usr/bin/ld: :(.data+0x508): undefined reference to `log2_rd'
# /usr/bin/ld: :(.data+0x558): undefined reference to `log10_rn'
# /usr/bin/ld: :(.data+0x55c): undefined reference to `log2_rn'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log2_rn_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:49: undefined reference to `log2_rn'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log2_rd_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:49: undefined reference to `log2_rd'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log2_ru_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:49: undefined reference to `log2_ru'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log2_rz_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:49: undefined reference to `log2_rz'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log10_rn_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:50: undefined reference to `log10_rn'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log10_rd_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:50: undefined reference to `log10_rd'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log10_ru_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:50: undefined reference to `log10_ru'
# /usr/bin/ld: src/libcrlibm_stubs.a(crlibm_stubs.o): in function `log10_rz_bc':
# /home/opam/.opam/4.13/.opam-switch/build/crlibm.0.5/_build/default/src/crlibm_stubs.c:50: undefined reference to `log10_rz'
# /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
# collect2: error: ld returned 1 exit status
# File "caml_startup", line 1:
# Error: Error during linking (exit code 1)

Is that expected?

@mseri mseri added the question label Nov 4, 2021
@Chris00 Chris00 force-pushed the release-crlibm-0.5 branch 4 times, most recently from 4607020 to 4afecb8 Compare November 5, 2021 06:13
@mseri
Copy link
Member

mseri commented Nov 5, 2021

If you want to try and reproduce it locally, you can follow the instructions on the top of the CI logs:

git clone --recursive "https://github.com/ocaml/opam-repository.git" && cd "opam-repository" && git fetch origin "refs/pull/19943/head" && git reset --hard 4afecb82
git fetch origin master
git merge c66dd4590bd215c9f95b36ed1c4047453a95dbaf
cat > ../Dockerfile <<'END-OF-DOCKERFILE'
FROM ocaml/opam:debian-11-ocaml-4.13@sha256:a77fc80588f2b127fbc53ae04a4d5f1b80f50157597a9b5981b8107b5ff74ebc
SHELL [ "/usr/bin/linux32", "/bin/sh", "-c" ]
USER 1000:1000
RUN opam repository remove -a multicore || true
RUN sudo ln -f /usr/bin/opam-2.1 /usr/bin/opam
RUN opam init --reinit -ni
ENV OPAMDOWNLOADJOBS 1
ENV OPAMERRLOGLEN 0
ENV OPAMSOLVERTIMEOUT 500
ENV OPAMPRECISETRACKING 1
WORKDIR /home/opam
RUN rm -rf opam-repository/
COPY --chown=1000:1000 . opam-repository/
RUN opam repository set-url --strict default "file://$HOME/opam-repository"
RUN opam pin add -k version -yn crlibm.0.5 0.5
RUN opam update --depexts
RUN opam remove crlibm.0.5 && opam install --deps-only crlibm.0.5 && opam install -v crlibm.0.5; \
    res=$?; \
    test "$res" != 31 && exit "$res"; \
    export OPAMCLI=2.0; \
    build_dir=$(opam var prefix)/.opam-switch/build; \
    failed=$(ls "$build_dir"); \
    for pkg in $failed; do \
    if opam show -f x-ci-accept-failures: "$pkg" | grep -qF "\"debian-11\""; then \
    echo "A package failed and has been disabled for CI using the 'x-ci-accept-failures' field."; \
    fi; \
    done; \
    exit 1
RUN opam update --depexts
RUN opam remove crlibm.0.5 && opam install --deps-only --with-test crlibm.0.5 && opam install -v --with-test crlibm.0.5; \
    res=$?; \
    test "$res" != 31 && exit "$res"; \
    export OPAMCLI=2.0; \
    build_dir=$(opam var prefix)/.opam-switch/build; \
    failed=$(ls "$build_dir"); \
    for pkg in $failed; do \
    if opam show -f x-ci-accept-failures: "$pkg" | grep -qF "\"debian-11\""; then \
    echo "A package failed and has been disabled for CI using the 'x-ci-accept-failures' field."; \
    fi; \
    done; \
    exit 1

END-OF-DOCKERFILE
docker build -f ../Dockerfile .

@mseri
Copy link
Member

mseri commented Nov 5, 2021

Big differences in output of successful and failing builds are the ld warning (present only on the 32bit build)

- /usr/bin/ld: src/crlibm.a(crlibm.o): warning: relocation in read-only section `.text'
- /usr/bin/ld: warning: creating DT_TEXTREL in a shared object

and the fact that the failing build is not complaining about /0 for all the log2 and log10 functions (which appear missing when linking)

@mseri
Copy link
Member

mseri commented Nov 5, 2021

Let me check if there is a CI issue, I am seeing similar failures on other packages as well

@Chris00
Copy link
Member Author

Chris00 commented Nov 5, 2021

Big differences in output of successful and failing builds are the ld warning (present only on the 32bit build)

I saw that but I do not get it: everything is compiled with -fPIC.

@mseri
Copy link
Member

mseri commented Nov 5, 2021

Yes, I saw, that is part of the reason why I start believing that these failures are a CI issue. I am seeing similar ones also in other packages

@mooreryan
Copy link
Contributor

PIC issues may be related to this: ocaml/ocaml#9800

CHANGES:

- Rename sub-modules to more standard names.
- Workaround 32 bits linker problem.
@Chris00
Copy link
Member Author

Chris00 commented Nov 5, 2021

@mseri I ran the following docker file

FROM ocaml/opam:debian-11-ocaml-4.13
SHELL [ "/usr/bin/linux32", "/bin/sh", "-c" ]
USER 1000:1000
RUN opam repository remove -a multicore || true
RUN sudo ln -f /usr/bin/opam-2.1 /usr/bin/opam
RUN opam init --reinit -ni
ENV OPAMDOWNLOADJOBS 1
ENV OPAMERRLOGLEN 0
ENV OPAMSOLVERTIMEOUT 500
ENV OPAMPRECISETRACKING 1
WORKDIR /home/opam
RUN rm -rf opam-repository/
COPY --chown=1000:1000 . crlibm/
RUN opam pin add -k path -yn crlibm.dev crlibm/
RUN opam update --depexts
RUN opam install --deps-only --with-test crlibm && opam install -v --with-test crlibm

but my machine is 64 bits and it runs fine.

@mseri
Copy link
Member

mseri commented Nov 5, 2021

That should run in 32 bits even on a 64-bit machine, or maybe you need to build it with

docker build --platform=linux/386 -f Dockerfile .

i will also try asap

@Chris00
Copy link
Member Author

Chris00 commented Nov 5, 2021

This yields:

failed to get destination image "sha256:871a1e5575f19b25e99f83b82c1a3ed24b14d295120f5937dc79586d13846bec": image with reference sha256:871a1e5575f19b25e99f83b82c1a3ed24b14d295120f5937dc79586d13846bec was found but does not match the specified platform: wanted linux/386, actual: linux/amd64

@mseri
Copy link
Member

mseri commented Nov 9, 2021

The first command to run the package was correct, without the platform, but you need to p oint at oune of the 32 bit images, like the one below (taken from the CI)
.
To reproduce our failures you can run

git clone --recursive "https://github.com/ocaml/opam-repository.git" && cd "opam-repository" && git fetch origin "refs/pull/19943/head" && git reset --hard e553d945
git fetch origin master
git merge 87ef72b5cd492573258eb1b6f3b30c88af31ae3f
cat > ../Dockerfile <<'END-OF-DOCKERFILE'
FROM ocaml/opam:debian-11-ocaml-4.13@sha256:0754672dc08f90477fff95b6489b92ff6020e63304fd1eabae57147ec40c4e90
SHELL [ "/usr/bin/linux32", "/bin/sh", "-c" ]
USER 1000:1000
RUN opam repository remove -a multicore || true
RUN sudo ln -f /usr/bin/opam-2.1 /usr/bin/opam
RUN opam init --reinit -ni
ENV OPAMDOWNLOADJOBS 1
ENV OPAMERRLOGLEN 0
ENV OPAMSOLVERTIMEOUT 500
ENV OPAMPRECISETRACKING 1
WORKDIR /home/opam
RUN rm -rf opam-repository/
COPY --chown=1000:1000 . opam-repository/
RUN opam repository set-url --strict default "file://$HOME/opam-repository"
RUN opam pin add -k version -yn crlibm.0.5 0.5
RUN opam update --depexts
RUN opam remove crlibm.0.5 && opam install --deps-only crlibm.0.5 && opam install -v crlibm.0.5; \
    res=$?; \
    test "$res" != 31 && exit "$res"; \
    export OPAMCLI=2.0; \
    build_dir=$(opam var prefix)/.opam-switch/build; \
    failed=$(ls "$build_dir"); \
    for pkg in $failed; do \
    if opam show -f x-ci-accept-failures: "$pkg" | grep -qF "\"debian-11\""; then \
    echo "A package failed and has been disabled for CI using the 'x-ci-accept-failures' field."; \
    fi; \
    done; \
    exit 1
RUN opam update --depexts
RUN opam remove crlibm.0.5 && opam install --deps-only --with-test crlibm.0.5 && opam install -v --with-test crlibm.0.5; \
    res=$?; \
    test "$res" != 31 && exit "$res"; \
    export OPAMCLI=2.0; \
    build_dir=$(opam var prefix)/.opam-switch/build; \
    failed=$(ls "$build_dir"); \
    for pkg in $failed; do \
    if opam show -f x-ci-accept-failures: "$pkg" | grep -qF "\"debian-11\""; then \
    echo "A package failed and has been disabled for CI using the 'x-ci-accept-failures' field."; \
    fi; \
    done; \
    exit 1

END-OF-DOCKERFILE
docker build -f ../Dockerfile .

You can execute the images that this produce to test your code with

docker run -it last_successfully_built_step_hash_in_the_output /usr/bin/linux32 bash

if you want to check what your fixes do on the CI environment. There is an issue on the discover.ml file in which you are checking system="linux" but on 32 bits linux this can be either "elf" or "linux_elf", but that is not enough to fix the compilation. Both the log2 and log10 functions are not compiled somehow on x86_32.

@kit-ty-kate
Copy link
Member

Thanks! Sorry for the wait

@kit-ty-kate kit-ty-kate merged commit 7ad7c3c into ocaml:master Nov 9, 2021
@Chris00 Chris00 deleted the release-crlibm-0.5 branch November 9, 2021 20:56
@Chris00
Copy link
Member Author

Chris00 commented Nov 9, 2021

Thanks for your help!

Chris00 added a commit to Chris00/ocaml-crlibm that referenced this pull request Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants