Re: Unresolved symbol in libQt6WebEngineCore.so.6.4.2

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Mon, 24 Jul 2023 12:50:48 UTC
Alexander Leidinger <Alexander@leidinger.net> writes:

> Quoting Jan Beich <jbeich@freebsd.org> (from Mon, 24 Jul 2023 13:52:43 +0200):
>
>> Alexander Leidinger <Alexander@leidinger.net> writes:
>>
>>> Hi,
>>>
>>> a build with non-standard port options (mostly nox11 und related stuff
>>> for a headless system, except for some ports where this doesn't work)
>>> is giving me an unresolved symbol in
>>> libQt6WebEngineCore.so.6.4.2. This symbol is
>>> _ZN7sandbox6policy12SandboxLinux11GetInstanceEv.
>>>
>>> I'm seeking some insight where this symbol comes from, so it would be
>>> nice if someone could report back if their
>>> libQt6WebEngineCore.so.6.4.2 also has this symbol as unresolved and
>>> which libary does provide this symbol via:
>>>   find /usr/local/lib -type f -print0 | xargs -0 nm -dynamic
>>>   --print-file-name | grep SandboxLinux
>>
>> The symbol is defined by WebEngine itself.
>>
>> $ cd www/qt6-webengine
>> $ make clean patch
>> $ cd `make -V WRKSRC`
>> $ rg -lF 'SandboxLinux::GetInstance() {'
>> src/3rdparty/chromium/sandbox/policy/linux/sandbox_linux.cc
>> src/3rdparty/chromium/sandbox/policy/openbsd/sandbox_openbsd.cc
>> src/3rdparty/chromium/sandbox/policy/freebsd/sandbox_freebsd.cc
>
> That doesn't sound promising. The qt6-webengine build succeeded, but
> this symbol is missing... :(
> As the port only has the audio options, it's not some direct influence
> which is causing it, but some indirect dependency on something in the
> dependecy chain I would assume.

If -Wl,--no-undefined (or -Wl,-z,defs) isn't passed then DSOs are
allowed to have unresolved references. This is useful for plugins
unlike shared libraries.

> I had a look at the faq and explanation of the sandbox at
> chromium.googlesource.com, but I didn't see any low level stuff which
> could help to identify why it isn't in the lib.

Check the build glue and/or ifdefs.

src/3rdparty/chromium/sandbox/policy/BUILD.gn:

  if ((is_linux || is_chromeos) && !is_bsd) {
    sources += [
    ...
      "linux/sandbox_linux.cc",
      "linux/sandbox_linux.h",
    ...
    ]
  ...
  }
  if (is_openbsd) {
    sources += [
      "openbsd/sandbox_openbsd.cc",
      "openbsd/sandbox_openbsd.h",
    ]
  ...
  }
  # Required to avoid assertion errors during build of QtPDF
  if (is_freebsd && ozone_platform_x11) {
    sources += [
      "freebsd/sandbox_freebsd.cc",
      "freebsd/sandbox_freebsd.h",
    ]
  ...
  }

src/3rdparty/chromium/build/config/ozone.gni:

    } else if (is_linux && !is_bsd) {
      ozone_platform = "x11"
      ozone_platform_wayland = true
      ozone_platform_x11 = true
    } else if (is_openbsd) {
      ozone_platform = "x11"
      ozone_platform_wayland = false
      ozone_platform_x11 = true
    } else if (is_freebsd) {
      ozone_platform = "x11"
      ozone_platform_wayland = true
      ozone_platform_x11 = true