Bug 251058

Summary: graphics/cairo: cannot build without X11 if mesa-libs was built without PLATFORM_X11
Product: Ports & Packages Reporter: robertostrander
Component: Individual Port(s)Assignee: freebsd-desktop (Team) <desktop>
Status: Closed Unable to Reproduce    
Severity: Affects Only Me CC: adridg, alexander, dpetrov67, freebsd-bugzillaqarmuxq9, tcberner
Priority: --- Flags: tcberner: maintainer-feedback+
Version: Latest   
Hardware: amd64   
OS: Any   
Bug Depends on: 246767    
Bug Blocks:    
Attachments:
Description Flags
Configure Log
none
Successful build log none

Description robertostrander 2020-11-11 20:22:41 UTC
Created attachment 219574 [details]
Configure Log

I'm building cairo from ports, and the configure script fails. In the config log attached, it says that it was unable to locate the OpenGL headers.

Specifically, "GL/gl.h"

The GL code I believe has been merged into mesa libs back in 2017, so, I'm not sure what I could try to resolve. Any pointers for a newb?
Comment 1 Tobias C. Berner freebsd_committer freebsd_triage 2020-11-12 06:06:23 UTC
Moin moin 


How are you building your ports? and ist the ports tree up to date?
Do you have both GL options turned off?


mfg Tobias
Comment 2 Niclas Zeising freebsd_committer freebsd_triage 2020-11-12 06:07:55 UTC
I can't reproduce this locally.
Do you have any special compile options or ports options somewhere?  Do you have mesa installed?
Comment 3 robertostrander 2020-11-13 03:57:14 UTC
Ports was updated on 2020 11 10, using:

` portsnap fetch
` portsnap update

To build the ports, I used portmaster -ar, since I had previously done a freebsd-update fetch, and freebsd-update install, then restarted the machine to apply kernel patches. I wanted all of the ports to be rebuilt, to avoid any potential ABI compatibility issues between FreeBSD versions.

The GL section has "OpenGL" starred, but not GLESV2.
Docs, GLIB, and XCB are also [x]'d in, but not X11.


Mesa is present, if I identified it correctly:

pkg-static info -g -Ea
[...]
mesa-libs-20.2.0_1             OpenGL libraries that support GLX and EGL clients
[...]
Comment 4 robertostrander 2020-11-22 21:59:05 UTC
Created attachment 219894 [details]
Successful build log

Later build which was successful after `make clean` on cairo, and mesa-libs
Comment 5 robertostrander 2020-11-22 22:00:31 UTC
** Summary **
I think this bug report stresses the importance of make clean, make clean-depends, and then further testing the build system to get more familiar with how it works.

At first, turning both GL options off for `graphics/cairo` allowed me to successfully build the port.

Below, you will see it has built now with the X11 flag checked

I ran make clean-depends on both ports directories for:
 - graphics/mesa-libs
 - graphics/cairo

Then rebuilt the ports.

graphics/mesa-libs was built with the following config on this re-run

===> The following configuration options are available for mesa-libs-20.2.0_1:
     WAYLAND=on: Enable support for the Wayland platform in EGL
     ZSTD=on: Use ZSTD for shader cache
====> Options available for the group PLATFORM
     PLATFORM_X11=on: Enable X11 support for GBM/EGL
     PLATFORM_WAYLAND=on: Enable Wayland support for GBM/EGL

graphics/cairo was built with the following config on this re-run:

===> The following configuration options are available for cairo-1.16.0_1,3:
     DOCS=on: Build and/or install documentation
     GLIB=on: Enable GObject Functions Feature
     X11=on: X11 (graphics) support
     XCB=on: Enable XCB (X C-language Binding) Support
====> Options available for the radio GL: you can only select none or one of them
     OPENGL=on: 2D/3D rendering support via OpenGL
     GLESV2=off: Enable GLESv2 rendering

The port built successfully.

`make deinstall`, then `make clean`, then `make configure` to uncheck X11 on graphics/cairo, also built successfully. Closing ticket report.
Comment 6 Alexander Ushakov 2020-11-25 09:37:19 UTC
I confirm the problem. Port has radio options: OPENGL and GLESV2. So one of them always is selected (default is OPENGL). But neither of this options has dependencies in Makefile. Therefore if I has no OpenGL port installed I'll get error:

checking whether cairo's OpenGL surface backend feature could be enabled... no (gl.pc nor OpenGL headers not found)
configure: error:  OpenGL surface backend feature could not be enabled
Comment 7 robertostrander 2020-11-29 16:11:46 UTC
Another person has confirmed the bug. Re-opening.
Comment 8 Jan Beich freebsd_committer freebsd_triage 2020-11-29 19:27:02 UTC
If mesa-libs was built with PLATFORM_X11 disabled then libGL.so won't exist, so `pkg-config gl` fails. However, the port passes --enable-gl because --enable-egl cannot be used standalone: needs either GLX (via X11) or GLESV2 but GLESV2 isn't enabled by default.

Without review D25020 fixing this is complicated: both basic OpenGL and X11 extensions are part of the same library. Until then enable GLESV2 instead of OPENGL. Upstream isn't active nowadays, and most distributions switched to libglvnd.
Comment 9 Alexander Ushakov 2020-12-01 10:54:37 UTC
Why cairo port must have OPENGL or GLESV2? Previously it works fine without them. And currently I can make it work when comment out all references to OpenGL.
I has this port installed because it is required for gitlab-ce. So I has no need neither in OpenGL nor GLESv2. May be it is better just to add an option NONE to the options list for those who doesn't need any rendering engine?
Comment 10 Jan Beich freebsd_committer freebsd_triage 2020-12-01 11:39:26 UTC
(In reply to Alexander Ushakov from comment #9)
> Why cairo port must have OPENGL or GLESV2?

GL is a radio option, so you can de-select both.
Comment 11 Alexander Ushakov 2020-12-01 15:08:53 UTC
> GL is a radio option, so you can de-select both.
Till October 2020 this radio option has no default value and works fine without selecting anything
Comment 12 Alexander Ushakov 2020-12-01 15:10:44 UTC
I suggest to add third value for this radio option - NONE. For users that want cairo without OpenGL or GLESv2
Comment 13 Jan Beich freebsd_committer freebsd_triage 2020-12-01 16:28:01 UTC
(In reply to Alexander Ushakov from comment #11)
> Till October 2020

Like before OPENGL is still default, like before OPENGL can still be de-selected (or un-selected, not sure which is correct term).

ports-mgmt/dialog4ports unlike "dialog --radiolist" supports not selecting anything. OPTIONS_RADIO != OPTIONS_SINGLE. For example, "make showconfig" prints the following:

  ====> Options available for the radio GL: you can only select none or one of them
                                                                ^^^^
adding NONE would increase maintenance and upset "portlint -C"

  WARN: Makefile: NONE is listed in OPTIONS_DEFINE, but no PORT_OPTIONS:MNONE appears.
Comment 14 Alexander Ushakov 2020-12-02 15:39:54 UTC
> OPENGL can still be de-selected (or un-selected, not sure which is correct term)
Oh, sorry, I didn't know that radio option can be unchecked. In that case port installs correctly.
May be add some checks to unselect option if there is no required libraries?
Comment 15 Jan Beich freebsd_committer freebsd_triage 2020-12-02 18:14:36 UTC
(In reply to Alexander Ushakov from comment #14)
> ... unselect option if there is no required libraries?

ports/ builds are supposed to be deterministic in order to be reproducible. What may help is polishing often used global options (e.g., OPTIONS_UNSET += X11 in make.conf) but it's a lot of hard work.
Comment 16 David Armstrong 2020-12-28 04:33:34 UTC
(In reply to Jan Beich from comment #10)

This is unexpected behaviour for radio buttons.  I too didn't realise it was possible to completely uncheck it, so had been wrestling with this issue too.

The port now builds with both X11 and OpenGL (and GLESv2) un-checked.  Thanks for the tip!
Comment 17 Adriaan de Groot freebsd_committer freebsd_triage 2022-04-10 19:40:18 UTC
Closing 257091 and 251058 because they seem to be related mis-configurations of ports. graphics/libglvnd and graphics/cairo both have option X11, default on, and Mesa builds with PLATFORM_X11. You need to have sufficiently-consistent ports options, and the current framework has no way of checking or enforcing sensible providers-options in consuming ports.

Note comments from 251058 (mostly from Jan Beich):
- relevant review has landed
- radio button can be switched off (it isn't an OPTIONS_SINGLE)

If there are specific settings (options, set in `make.conf`) that should make sense, but fail to build, then please open another PR with explicit and detailed steps to reproduce (e.g. "start with a fresh 12.3 VM, portsnap fetch extract, then use this make.conf, build graphics/cairo with BATCH=1 and notice it failing like-so")