Bug 274542 - devel/llvm: C99 include files are not included
Summary: devel/llvm: C99 include files are not included
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Brooks Davis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-17 17:31 UTC by Brendan Shanks
Modified: 2024-09-08 04:54 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (brooks)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brendan Shanks 2023-10-17 17:31:41 UTC
The LLVM ports do not include various standard C/C99 headers because of this patch: <https://cgit.freebsd.org/ports/tree/devel/llvm17/files/patch-clang_lib_Headers_CMakeLists.txt>

My specific problem is that this prevents Wine from using LLVM/clang from ports as a PE cross-compiler. In this case Wine uses clang in the 'x86_64-windows' mode, configure does a check in this mode and tries to build a sample file which includes <stddef.h>, and this fails.
LLVM/clang packages on other OSes (Gentoo Linux, macOS Homebrew) do include these files.

And more generally, anyone trying to use ports LLVM/clang to target a  freestanding/bare-metal environment would not be able to use any of these standard header files.
E.g. for a very simple test.c:
#include <stdint.h>

uint64_t hi(void)
{
        return 1;
}

and build with:
$ /usr/local/bin/clang --target=arm-none-eabi -nostdlib -o test.o test.c
Comment 1 Brooks Davis freebsd_committer freebsd_triage 2023-11-30 21:57:14 UTC
We either need to patch FreeBSD's include files so that it can build with the llvm ones installed or patch the llvm ones to honor FreeBSD's guard macros.  I'm not sure which is the best approach, but until that's resolved we're stuck in this situation.
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-05-28 12:04:24 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c56fde6514ee21ccb186267c304ad444463f661c

commit c56fde6514ee21ccb186267c304ad444463f661c
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-05-28 11:47:37 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-05-28 11:56:43 +0000

    devel/llvm18: misc improvements

    Fix worse runtime performance on Zen CPU when optimizing for Zen. [0]

    Install all standard heaaders with clang.  Historically we've been
    unable to build FreeBSD with the full set due to conflicts and/or
    missing features between the compiler provided headers and
    FreeBSD's headers.  I've verified that I can build world and kernel on
    the main, stable/14, and stable/13 branches for amd64 so let's give it
    another try in broader testing. [1]

    PR:             278908 [0], 274542 [1]

 devel/llvm18/Makefile                              |  2 +-
 .../patch-clang_lib_Headers_CMakeLists.txt (gone)  | 37 ----------
 .../llvm18/files/patch-freebsd-cadd2ca21765 (new)  | 83 ++++++++++++++++++++++
 devel/llvm18/pkg-plist                             | 25 +++++++
 4 files changed, 109 insertions(+), 38 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-06-11 23:36:40 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b21e6b4de126e3a8053c792714456bd8dd3ceefb

commit b21e6b4de126e3a8053c792714456bd8dd3ceefb
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-06-11 23:25:58 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2024-06-11 23:26:15 +0000

    devel/llvm17: install all heaaders with clang

    Historically we've been unable to build FreeBSD with the full set due to
    conflicts and/or missing features between the compiler provided headers
    and FreeBSD's headers. I've verified that I can build world and kernel
    on the main, stable/14, and stable/13 branches for amd64 so let's give
    it another try in broader testing.

    PR:             274542

 devel/llvm17/Makefile                              |  2 +-
 .../patch-clang_lib_Headers_CMakeLists.txt (gone)  | 22 ----------------------
 devel/llvm17/pkg-plist                             |  9 +++++++++
 3 files changed, 10 insertions(+), 23 deletions(-)
Comment 4 Anton Saietskii 2024-06-22 12:06:37 UTC
(In reply to commit-hook from comment #3)

So, here's a report of broader testing: this (and previous) commit broke emulators/wine packaging unfortunately, please see #279677 for details.
Comment 5 Gerald Pfeifer freebsd_committer freebsd_triage 2024-06-23 00:42:30 UTC
I have an update for emulators/wine-devel in the works where these
changes actually are *required* to move to Wine 9.9 or later. And 
if things work out as expected plan on pushing back these changes
to emulators/wine as well. (Timing is not too critical since the
packaging issues with emulators/wine only happen when one changes
LLVM_DEFAULT to 17 or 18.)

Brooks, are you planning to push back your changes to devel/llvm16?
Comment 6 commit-hook freebsd_committer freebsd_triage 2024-06-23 08:08:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5f69b17e49a9cc392392e9d91d600a4e48fcb50c

commit 5f69b17e49a9cc392392e9d91d600a4e48fcb50c
Author:     Gerald Pfeifer <gerald@FreeBSD.org>
AuthorDate: 2024-06-23 08:06:01 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2024-06-23 08:06:01 +0000

    emulators/wine-devel: Update to Wine 9.9

    This includes the following changes:
     - Removal of a number of obsolete features in WineD3D.
     - Support for new WoW64 mode in ODBC.
     - Various bug fixes.

    When trying to build with LLVM 15, which is the current default in
    the Ports Collection we have been using for a while, we now get the
    following error:

      configure: error: Suitable PE cross-compiler not found, PE files
      won't be built. This is an error since --with-mingw was requested.
      ===>  Script "configure" failed unexpectedly.

    This is not actually a regression from Wine 9.8 to 9.9; rather Wine
    now diagnoses this (again) instead of simply proceeding.

    Luckily our devel/llvm18 and devel/llvm17 ports just recently addressed
    the situation with commits c56fde6514 on May 28 and b21e6b4de1 on June 12,
    respectively. Accordingly force the use of at least devel/llvm17. [2]

    This brings a huge number of changes in terms of pkg-plist.

    (The emulators/wine port will need similar changes or it'll break
    with builds of LLVM that contain these changes already in the two
    ports above. [1])

    PR:             279677 [1], 274542 [2]

 emulators/wine-devel/Makefile  |  10 +-
 emulators/wine-devel/distinfo  |   6 +-
 emulators/wine-devel/pkg-plist | 999 ++++++++++-------------------------------
 3 files changed, 243 insertions(+), 772 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-07-03 12:13:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b65e6c38fd055e913a4ce458d5c774c715a5ea9b

commit b65e6c38fd055e913a4ce458d5c774c715a5ea9b
Author:     Gerald Pfeifer <gerald@FreeBSD.org>
AuthorDate: 2024-07-03 12:08:37 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2024-07-03 12:09:54 +0000

    emulators/wine: Firmly depend on LLVM 15

    Our devel/llvm18 and devel/llvm17 ports (with commits c56fde6514 and
    b21e6b4de1, respectively) now provide C99 include files.[1]  This is
    a positive and fixes a long standing issue. It significantly changes
    what Wine builds, though. For emulators/wine-devel we moved to the new
    world order already; for emulators/wine remain a bit more conservative
    and stay with status quo ante by firmly using LLVM 15.

    For most users this won't make any difference since so far we have
    been using LLVM_DEFAULT which currently stands at ... 15.

    On the way use the new USES=llvm facility instead of doing things
    more manually.

    PR:             279677, 274542 [1]

 emulators/wine/Makefile | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
Comment 8 Brendan Shanks 2024-08-30 18:00:54 UTC
Thanks all, this seems fixed now. devel/llvm now includes all the header files, and can be used as a PE cross-compiler by Wine.
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-09-08 04:54:49 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4beb3216818c58ae4d1d53734957660ee99ecd24

commit 4beb3216818c58ae4d1d53734957660ee99ecd24
Author:     Gerald Pfeifer <gerald@FreeBSD.org>
AuthorDate: 2024-09-08 04:53:03 +0000
Commit:     Gerald Pfeifer <gerald@FreeBSD.org>
CommitDate: 2024-09-08 04:53:04 +0000

    emulators/wine: Fix the PE build

    This requires our devel/llvm17 or later ports which bring full header
    files. [1]

    It has major impact on how this port is built and the packaging list,
    so bump PORTREVISION.

    PR:             280448, 274542 [1], 279677 [1]

 emulators/wine/Makefile  |   5 +-
 emulators/wine/pkg-plist | 993 +++++++++++------------------------------------
 2 files changed, 233 insertions(+), 765 deletions(-)