From nobody Fri May 24 16:14:03 2024 X-Original-To: freebsd-arch@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vm98l71BFz5LL9d; Fri, 24 May 2024 16:14:15 +0000 (UTC) (envelope-from bshanks@codeweavers.com) Received: from mail.codeweavers.com (mail.codeweavers.com [4.36.192.163]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vm98l3PLWz42rg; Fri, 24 May 2024 16:14:15 +0000 (UTC) (envelope-from bshanks@codeweavers.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=codeweavers.com header.s=s1 header.b=cxJIzviw; dmarc=pass (policy=none) header.from=codeweavers.com; spf=pass (mx1.freebsd.org: domain of bshanks@codeweavers.com designates 4.36.192.163 as permitted sender) smtp.mailfrom=bshanks@codeweavers.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=s1; h=To:Cc:Date:Message-Id:Subject:From:Sender; bh=lJ9gqRn18XhpAYOs9ZRYa1PMa8NXBTbWsWBKzA0AGyM=; b=cxJIzviw/NQqKGH/LY+O19+5ww HPqtzmsrpikIb5SMb50vQPSTj1GhIxinF8CzwoXvTTpXfnnvz7tilHUAQrKRRXqIhHQYeUciFjpof L7Uhq/3RFcmA9g+b1m5fxT08kZGUlnIWbRsoUOrwhYj/WDDT8k4Mga9frxX8wnKq138txEYAXA2tu AawmQJi2QmkK0jTYVrbrI/Pzsx76uCHKFQT23k1arRYcMhGo6HvQ3KhstTNnLX+//TpY2O92VYKIm 0IDuq08NTRuMAh2dEXnsR1HmU81p+3gH7Z3ndZarLTkHVgjDPFpvg8Jtu1mtD6T0Vio4Gedq+Aucq SSlt/pIQ==; Received: from [10.69.139.4] (helo=smtpclient.apple) by mail.codeweavers.com with esmtpsa (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sAXYc-002fbp-2q; Fri, 24 May 2024 11:14:15 -0500 From: Brendan Shanks Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: Discussion related to FreeBSD architecture List-Archive: https://lists.freebsd.org/archives/freebsd-arch List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arch@FreeBSD.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Using standard C headers from LLVM/Clang Message-Id: Date: Fri, 24 May 2024 09:14:03 -0700 Cc: freebsd-arch@freebsd.org To: freebsd-toolchain@freebsd.org X-Mailer: Apple Mail (2.3774.600.62) X-Spamd-Bar: ---- X-Spamd-Result: default: False [-5.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DWL_DNSWL_LOW(-1.00)[codeweavers.com:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; DMARC_POLICY_ALLOW(-0.50)[codeweavers.com,none]; R_DKIM_ALLOW(-0.20)[codeweavers.com:s=s1]; R_SPF_ALLOW(-0.20)[+ip4:4.36.192.163:c]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; ASN(0.00)[asn:3356, ipnet:4.0.0.0/9, country:US]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_ONE(0.00)[1]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; APPLE_MAILER_COMMON(0.00)[]; TO_DN_NONE(0.00)[]; MLMMJ_DEST(0.00)[freebsd-toolchain@freebsd.org,freebsd-arch@freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[codeweavers.com:+] X-Rspamd-Queue-Id: 4Vm98l3PLWz42rg Hi all, I work for CodeWeavers, contributing to the Wine project. When building = Wine on FreeBSD, I found that Wine refuses to use LLVM/clang from ports = as a PE cross-compiler because the standard C/C99 headers are not = present. In this case Wine uses clang in the 'x86_64-windows' mode, = which understandably doesn=E2=80=99t use includes from /usr/include. = configure tries to build a sample file in this mode which includes = , and this fails. Normally clang would have its own version of the standard C header files = to use, but FreeBSD doesn=E2=80=99t install these: = , = . To work around this, the wine-devel FreeBSD port actually includes = clang's stdarg.h to satisfy configure. But besides Wine=E2=80=99s usage, anyone trying to use ports clang to = target a freestanding/bare-metal environment would not be able to use = any of these standard header files. I filed a bug for this: = = ("devel/llvm: C99 include files are not included=E2=80=9D), and the = advice was that either the FreeBSD or clang headers would need patches = so they can coexist. I thought I=E2=80=99d start on this by creating a GitHub pull request = () to use iso646.h and = varargs.h from clang, and remove the FreeBSD versions. These files are = very simple, and the two versions are functionally identical. The advice there was that this is a bigger philosophical change, and = should be discussed further. My question for everyone: should the Clang C headers be used instead of = FreeBSD maintaining its own? Is there still a philosophical reason for FreeBSD to maintain its own = set of C header files? My opinion is that the Clang headers should be used when possible. For one, it would fix this bug which cripples Clang when cross-compiling = for other architectures. Also, supporting new versions of C (like C23) may need changes in both = the compiler and headers. FreeBSD=E2=80=99s headers are certainly not = being updated as regularly as LLVM=E2=80=99s. Lastly, I don=E2=80=99t know what the benefit is of FreeBSD having its = own copy of these. In a quick survey of the other OSes I use (Gentoo Linux, macOS Xcode and = Homebrew), they all use LLVM=E2=80=99s header files. An alternate option would be to leave the system headers in-place, but = also install the Clang versions (e.g. both = /usr/lib/clang/16/include/stdint.h and /usr/include/stdint.h would = exist). This would work, but it would be confusing to have 2 versions of = these files. GCC from ports includes its own iso646.h and varargs.h, and = I believe Clang would also be using its own. Thank you! Brendan