Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 2225813 - freetennis: FTBFS in Fedora rawhide/f39
Summary: freetennis: FTBFS in Fedora rawhide/f39
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: freetennis
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Hans de Goede
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: F39FTBFS
TreeView+ depends on / blocked
 
Reported: 2023-07-25 17:40 UTC by Fedora Release Engineering
Modified: 2023-08-06 15:59 UTC (History)
4 users (show)

Fixed In Version: freetennis-0.4.8-56.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-08-06 15:59:55 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
build.log (deleted)
2023-07-25 17:40 UTC, Fedora Release Engineering
no flags Details
root.log (deleted)
2023-07-25 17:40 UTC, Fedora Release Engineering
no flags Details
state.log (deleted)
2023-07-25 17:40 UTC, Fedora Release Engineering
no flags Details

Description Fedora Release Engineering 2023-07-25 17:40:35 UTC
freetennis failed to build from source in Fedora rawhide/f39

https://koji.fedoraproject.org/koji/taskinfo?taskID=103575662


For details on the mass rebuild see:

https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Please fix freetennis at your earliest convenience and set the bug's status to
ASSIGNED when you start fixing it. If the bug remains in NEW state for 8 weeks,
freetennis will be orphaned. Before branching of Fedora 40,
freetennis will be retired, if it still fails to build.

For more details on the FTBFS policy, please visit:
https://docs.fedoraproject.org/en-US/fesco/Fails_to_build_from_source_Fails_to_install/

Comment 1 Fedora Release Engineering 2023-07-25 17:40:39 UTC
Created attachment 1977912 [details]
build.log

Comment 2 Fedora Release Engineering 2023-07-25 17:40:43 UTC
Created attachment 1977913 [details]
root.log

file root.log too big, will only attach last 32768 bytes

Comment 3 Fedora Release Engineering 2023-07-25 17:40:45 UTC
Created attachment 1977914 [details]
state.log

Comment 4 Hans de Goede 2023-07-30 19:36:50 UTC
So the error here is:

File "_none_", line 1:
Alert ocaml_deprecated_auto_include: 
OCaml's lib directory layout changed in 5.0. The unix subdirectory has been
automatically added to the search path, but you should add -I +unix to the
command-line to silence this alert (e.g. by adding unix to the list of
libraries in your dune file, or adding use_unix to your _tags file for
ocamlbuild, or using -package unix for ocamlfind).

File "freetennis.ml", line 6654, characters 31-47:
6654 |      let mayb = translateName (String.lowercase !p0Name ) in
                                      ^^^^^^^^^^^^^^^^
Error: Unbound value String.lowercase

I'm afraid my ocaml skills are pretty much non existent. Does this Unbound value String.lowercase indicate a missing include or ...?

I could certainly use some help with this from someone more versed in ocaml.

Comment 5 Richard W.M. Jones 2023-07-30 19:41:48 UTC
The warning is saying that the freetennis build system / makefiles have to be changed
to add `-I +unix' to the ocaml compiler command line.

However the actual error is different.  The String.lowercase function in OCaml <= 4.12
only worked on ISO-8859-1 strings.  As a result it wasn't very useful for modern
systems.  This function has been removed in OCaml 5, but there is a replacement
String.lowercase_ascii.  It only works with 7-bit ASCII strings, but I'm sure it'll
be fine here.  (For UTF-8 you'd need to add an external library).

I think simply patching the code with s/String.lowercase/String.lowercase_ascii/g
is practically all you'd need to do here.

Comment 6 Richard W.M. Jones 2023-07-30 19:42:46 UTC
See also /usr/lib64/ocaml/string.mli

Comment 7 Hans de Goede 2023-08-04 21:02:16 UTC
Richard, thank you for the help.

I'm getting much further now.

After fixing the first set of errors I got an error about bigarray.cmxa not being found, with ocaml 5.0 there is a bigarray.mli file instead so I just dropped bigarray.cmxa from the ocamlopt invocation.

That seems to work, but now I'm getting an error about unresolved symbols in the ocaml SDL bindings:

/usr/bin/ld: /usr/lib64/ocaml/sdl/libsdlstub.a(sdlevent_stub.o): in function `mlsdlevent_wait':
(.text+0x115e): undefined reference to `enter_blocking_section'
/usr/bin/ld: (.text+0x116c): undefined reference to `leave_blocking_section'
/usr/bin/ld: /usr/lib64/ocaml/sdl/libsdlstub.a(sdlevent_stub.o): in function `mlsdlevent_wait_event':
(.text+0x11ad): undefined reference to `enter_blocking_section'
/usr/bin/ld: (.text+0x11bd): undefined reference to `leave_blocking_section'
/usr/bin/ld: /usr/lib64/ocaml/sdl/libsdlstub.a(sdltimer_stub.o): in function `sdltimer_delay':
(.text+0x14): undefined reference to `enter_blocking_section'
/usr/bin/ld: (.text+0x21): undefined reference to `leave_blocking_section'
/usr/bin/ld: /usr/lib64/ocaml/sdl/libsdlstub.a(sdlgl_stub.o): in function `ml_SDL_GL_SwapBuffers':
(.text+0x9): undefined reference to `enter_blocking_section'
/usr/bin/ld: (.text+0x13): undefined reference to `leave_blocking_section'
collect2: error: ld returned 1 exit status

Is this an issue with the SDL bindings; or do I need to add something to the ocamlopt invocation to add an extra lib to the ld command with these symbols ?

Comment 8 Richard W.M. Jones 2023-08-04 21:24:45 UTC
Jerry added this patch to make ocaml-SDL compile with OCaml 5:

https://src.fedoraproject.org/rpms/ocaml-SDL/blob/rawhide/f/ocamlsdl-0.9.1-ocaml5.patch

Notice that it deals with a change in OCaml 5 where you are no longer allowed
to use un-namespaced symbols in the OCaml runtime (like "alloc_small") but must
use namespaced symbols instead ("caml_alloc_small").

caml_enter_blocking_section / caml_leave_blocking_section are also symbols
in the OCaml runtime, and my theory is that this patch is incomplete and there
are un-namespaced uses of enter_blocking_section etc still in the code, in
fact like these ones:

$ grep -E '(enter|leave)_blocking_section' src/*.c
src/sdlevent_stub.c:  enter_blocking_section();
src/sdlevent_stub.c:  leave_blocking_section();
src/sdlevent_stub.c:  enter_blocking_section();
src/sdlevent_stub.c:  leave_blocking_section();
src/sdlgl_stub.c:  enter_blocking_section();
src/sdlgl_stub.c:  leave_blocking_section();
src/sdlloader_stub.c:  enter_blocking_section();
src/sdlloader_stub.c:  leave_blocking_section();
src/sdltimer_stub.c:  enter_blocking_section();
src/sdltimer_stub.c:  leave_blocking_section();

So I will push an extra patch to ocaml-SDL shortly, which might fix this.

Comment 9 Richard W.M. Jones 2023-08-04 21:32:22 UTC
ocaml-SDL-0.9.1-62.fc39
https://koji.fedoraproject.org/koji/taskinfo?taskID=104368014

> After fixing the first set of errors I got an error about bigarray.cmxa not
> being found, with ocaml 5.0 there is a bigarray.mli file instead so I just
> dropped bigarray.cmxa from the ocamlopt invocation.

This seems dubious to me.  I think the change you might need to make it to
add '-I +bigarray' to the ocamlopt command line.

Comment 10 Jerry James 2023-08-04 21:52:49 UTC
Oops, sorry for overlooking some of those symbols.

(In reply to Richard W.M. Jones from comment #9)
> ocaml-SDL-0.9.1-62.fc39
> https://koji.fedoraproject.org/koji/taskinfo?taskID=104368014
> 
> > After fixing the first set of errors I got an error about bigarray.cmxa not
> > being found, with ocaml 5.0 there is a bigarray.mli file instead so I just
> > dropped bigarray.cmxa from the ocamlopt invocation.
> 
> This seems dubious to me.  I think the change you might need to make it to
> add '-I +bigarray' to the ocamlopt command line.

Actually, I think Hans has it right.  From the OCaml 5.0.0 announcment (https://discuss.ocaml.org/t/ocaml-5-0-0-is-out/10974):

(breaking change) #10896 8: Remove Stream, Genlex and Pervasives. Also remove legacy standalone
bigarray library (the Bigarray module is now part of the standard library).
(Nicolás Ojeda Bär, review by Kate Deplaix and Anil Madhavapeddy)

Comment 11 Hans de Goede 2023-08-05 19:01:34 UTC
> ocaml-SDL-0.9.1-62.fc39
> https://koji.fedoraproject.org/koji/taskinfo?taskID=104368014

Thanks based on a local mockbuild that seems to have done the trick. I'm starting a proper koji build with the fixes now.

Comment 12 Hans de Goede 2023-08-06 14:38:53 UTC
> I'm starting a proper koji build with the fixes now.

Almost there. The i686 and ppc64le builds failed.

I see that ocaml5 / F39 does not support ocaml on 32 bit x86 so fixing this is just duplicating the:

```
# i686 support was dropped in OCaml 5 / Fedora 39.
ExcludeArch: %{ix86}
```

Lines from ocaml.spec

ppc64le also should be easy to fix I think. The issue is there is no ocamlopt command on ppc64le anymore with ocaml5 ?

```
+ make -j8
ocamlopt   -I +camlimages  -I +lablGL -I +lablgtk2    -I +sdl -I +unix -o freetennis  sdl.cmxa lablgtk.cmxa lablgl.cmxa sdlmixer.cmxa sdlttf.cmxa unix.cmxa freetennis.ml
make: ocamlopt: No such file or directory
make: *** [Makefile:3: all] Error 127
```

So I guess I should do something like this:

%ifnarch %{ocaml_native_compiler}
sed -i 's/ocamlopt/ocaml/' Makefile
%endif

?

Comment 13 Hans de Goede 2023-08-06 15:11:55 UTC
Ok, that is not correct, I think the correct sed is:

sed -i -e 's/ocamlopt/ocamlc/g' -e 's/cmxa/cma/g' Makefile

I'm doing a pcc64le only scratch-build with that now.

If that succeeds I'll kick of a real build, because after reading some docs I'm reasonably sure that this is the right thing to do.

Comment 14 Jerry James 2023-08-06 15:16:20 UTC
You are going to need to invoke ocamlc instead of ocamlopt, and you will probably need to add -output-complete-exe to the build flags as well.  If you'll give me a few minutes, I'll look this over and see if any other tweaks are needed.

Comment 15 Hans de Goede 2023-08-06 15:24:42 UTC
(In reply to Jerry James from comment #14)
> You are going to need to invoke ocamlc instead of ocamlopt, and you will
> probably need to add -output-complete-exe to the build flags as well.  If
> you'll give me a few minutes, I'll look this over and see if any other
> tweaks are needed.

Ok, thanks.

Note this builds on ppc64le (but I have not tested it):

diff --git a/freetennis.spec b/freetennis.spec
index 7198ebc..94f3253 100644
--- a/freetennis.spec
+++ b/freetennis.spec
@@ -21,6 +21,8 @@ BuildRequires:  ocaml-camlimages-devel
 BuildRequires:  ocaml-SDL-devel >= 0.9.1-34
 BuildRequires:  ocaml-lablgl-devel >= 1.06-1
 BuildRequires:  ocaml-lablgtk-devel >= 2.10.1-5
+# i686 support was dropped in OCaml 5 / Fedora 39.
+ExcludeArch:    %{ix86}
 
 %description
 Free Tennis is a free software tennis simulation game.  The game can be 
@@ -29,6 +31,9 @@ played against an A.I. or human-vs-human via LAN or internet.
 
 %prep
 %autosetup -p1
+%ifnarch %{ocaml_native_compiler}
+sed -i -e 's/ocamlopt/ocamlc/g' -e 's/cmxa/cma/g' Makefile
+%endif
 
 
 %build


I guess the -output-complete-exe is necessary to also include the sdl and lablgtk bytecode inside the bytecode based binary ?

Maybe an alternative would be to add Requires: to the non devel parts of the necessary libs in the %ifnarch %{ocaml_native_compiler} case ?

Comment 16 Richard W.M. Jones 2023-08-06 15:36:15 UTC
Note the absence of the native compiler on ppc64le, s390x & riscv64 is
temporary and we expect those compiler back ends to be ported in OCaml 5.1.
i686 ain't never coming back.

Comment 17 Jerry James 2023-08-06 15:36:34 UTC
(In reply to Hans de Goede from comment #15)
> diff --git a/freetennis.spec b/freetennis.spec
> index 7198ebc..94f3253 100644
> --- a/freetennis.spec
> +++ b/freetennis.spec
> @@ -21,6 +21,8 @@ BuildRequires:  ocaml-camlimages-devel
>  BuildRequires:  ocaml-SDL-devel >= 0.9.1-34
>  BuildRequires:  ocaml-lablgl-devel >= 1.06-1
>  BuildRequires:  ocaml-lablgtk-devel >= 2.10.1-5
> +# i686 support was dropped in OCaml 5 / Fedora 39.
> +ExcludeArch:    %{ix86}

This spec file already has an ExcludeArch, so I think you will want to combine them.

> I guess the -output-complete-exe is necessary to also include the sdl and
> lablgtk bytecode inside the bytecode based binary ?

Right.

> Maybe an alternative would be to add Requires: to the non devel parts of the
> necessary libs in the %ifnarch %{ocaml_native_compiler} case ?

I don't see why that would be better, even if it works.  The advantage of using -output-complete-exe is that stripping the output binary does not remove the bytecode payload.   This package disables debuginfo generation anyway, so it doesn't matter ... except there is no reason for this package to disable debuginfo generation.  All that is missing is the -g flag for ocamlopt / ocamlc.  I've got several improvements to suggest for this package now, and have verified that the ppc64le build works with my approach, too.  I'll open a PR momentarily and you can choose whether to merge it or not, or to cherry pick from it if you don't like all of it.

Comment 19 Hans de Goede 2023-08-06 15:46:02 UTC
(In reply to Jerry James from comment #18)
> https://src.fedoraproject.org/rpms/freetennis/pull-request/1

Thank you. This looks good to me I'll merge this and then start a new build.

Comment 20 Fedora Update System 2023-08-06 15:57:47 UTC
FEDORA-2023-5e9a88ebc4 has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-5e9a88ebc4

Comment 21 Fedora Update System 2023-08-06 15:59:55 UTC
FEDORA-2023-5e9a88ebc4 has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.