From patchwork Tue Aug 6 23:09:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Gomez via B4 Relay X-Patchwork-Id: 13755441 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C414175D36; Tue, 6 Aug 2024 23:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722985803; cv=none; b=C9Co98XRZCnGA7XDLLJs+3PgZitmSxvlZ+PwO3xWFjojlTbLYMipEaveWo3oGck79bIz0aLmDipxGQEcjy1EfJdgku21R7ak8KanTIVClW4oR+zHCr6rfrPYAXkJljEGOVpIhmcOWxi72W6I6yOvjeL1N+ZQYFIqFhLvGtY+uzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722985803; c=relaxed/simple; bh=srDtPMkx+3Ib/2vxXDsh66x8GKusBSCFnXcAPZ0/fJs=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=NrX/0vj3hSccTxNv+2yDRxsRnitgFZAmoDvOv39JapwOuQdSGag4A2uW+OnOHFI52IX7n3/g9b7XrV4cZ6GigjXXVYfDZwt5H2ZA0jKfLhXZNX13U5fzpkIFEJyWpTFzQCIB0gSeC8Z6EU3aMfvIkba/AwHhbCfvpkjkknlkC78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XyM4t6ui; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XyM4t6ui" Received: by smtp.kernel.org (Postfix) with ESMTPS id B3CB0C32786; Tue, 6 Aug 2024 23:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722985802; bh=srDtPMkx+3Ib/2vxXDsh66x8GKusBSCFnXcAPZ0/fJs=; h=From:Subject:Date:To:Cc:Reply-To:From; b=XyM4t6uixRdVtkkTDbe0NOXLXZ37CozxQGFZMrfsO/1RoZeoVND7Z91irbEFkZG1o QK9utNoPH7ktjzxgS9PHoD3qn/DNgqvVdZsgReOQMjUrT2TlQWFkqaNximTlbkANJw fwIaCs8OsL+5RpaxQ7RQgnnJNhR2sK1DHuPhkA26DmsSHTA9hDidEKUXDf1733zm99 S42u2FVCM/ikVhxmWNb19aaYerJ5H8KgfmYrOTZTuTaNNyjHX7w/yoQnm1GFvnWvt/ BEBQiXjUFnQg6HPQgb/LURhqtACOPKxOuV9p3+Gjq6Aluocc6VajyOLbdkqKccoIPM bvFunUNgxUrOA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96120C49EA1; Tue, 6 Aug 2024 23:10:02 +0000 (UTC) From: Daniel Gomez via B4 Relay Subject: [PATCH 00/12] Enable build system on macOS hosts Date: Wed, 07 Aug 2024 01:09:14 +0200 Message-Id: <20240807-macos-build-support-v1-0-4cd1ded85694@samsung.com> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIABqtsmYC/x3MQQqAIBBA0avErBuwCKyuEi1MpxqoFCcjiO6et HyL/x8QikwCffFApIuF/ZFRlQXY1RwLIbtsqFXdqFZp3I31glPizaGkEHw8sbNGOa2NmyoNuQy RZr7/6zC+7wcg7OjoZQAAAA== To: Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Lucas De Marchi , =?utf-8?q?Thomas_Hellstr=C3=B6?= =?utf-8?q?m?= , Rodrigo Vivi , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , William Hubbs , Chris Brannon , Kirk Reiser , Samuel Thibault , Paul Moore , Stephen Smalley , Ondrej Mosnacek , Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Greg Kroah-Hartman , Jiri Slaby , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, speakup@linux-speakup.org, selinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-serial@vger.kernel.org, llvm@lists.linux.dev, Finn Behrens , "Daniel Gomez (Samsung)" , gost.dev@samsung.com, Daniel Gomez , Nick Desaulniers X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1722985800; l=5760; i=da.gomez@samsung.com; s=20240621; h=from:subject:message-id; bh=srDtPMkx+3Ib/2vxXDsh66x8GKusBSCFnXcAPZ0/fJs=; b=LiLIkclk6gyjYUEvcQG/jWd8xczYA+IguM7XsmOaFyvBmuk7FzB0cX6xsiSYYX3g4q3i4pKTn rvltGN/7ZboBznQAO+ngrBCel8MYDLLj7yJ1vi5dIVQBZPHBahIv5wm X-Developer-Key: i=da.gomez@samsung.com; a=ed25519; pk=BqYk31UHkmv0WZShES6pIZcdmPPGay5LbzifAdZ2Ia4= X-Endpoint-Received: by B4 Relay for da.gomez@samsung.com/20240621 with auth_id=175 X-Original-From: Daniel Gomez Reply-To: da.gomez@samsung.com This patch set allows for building the Linux kernel for arm64 in macOS with LLVM. Patches are based on previous Nick's work and suggestions [1][2][3] to enable build system in macOS hosts. Since macOS does not provide some of the headers available in the GNU C Library (glibc), the patches include a copy of these headers from glibc-2.40, with minor modifications detailed in the commit message. To set up the environment: * Provide build dependencies (installed via Homebrew): coreutils, findutils, gnu-sed, gnu-tar, grep, llvm, make and pkg-config. * A case sensitive volume for building: diskutil apfs addVolume /dev/disk "Case-sensitive APFS" linux * And include in your PATH all GNU tools required by the Linux kernel as well as LLVM: PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/gnu-tar/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH" PATH="/opt/homebrew/opt/llvm/bin:$PATH" * Start the build using LLVM: make LLVM=1 allyesconfig make LLVM=1 -j$(nproc) I believe other architectures could also be supported if we can move forward this initiative. Additionally, we could incorporate Rust support. I understand that Finn Behrens has some patches [4][5] based on Nick's previous work. [1]: WIP: build Linux on MacOS https://github.com/ClangBuiltLinux/linux/commit/f06333e29addbc3d714adb340355f471c1dfe95a [2] Subject: [PATCH] scripts: subarch.include: fix SUBARCH on MacOS hosts https://lore.kernel.org/all/20221113233812.36784-1-nick.desaulniers@gmail.com/ [3] Subject: Any interest in building the Linux kernel from a MacOS host? https://lore.kernel.org/all/CAH7mPvj64Scp6_Nbaj8KOfkoV5f7_N5L=Tv5Z9zGyn5SS+gsUw@mail.gmail.com/ [4] https://github.com/kloenk/linux/commits/rust-project_macos-dylib/ [5] https://kloenk.eu/posts/build-linux-on-m1-macos/ To: Masahiro Yamada To: Nathan Chancellor To: Nicolas Schier To: Lucas De Marchi To: Thomas Hellström To: Rodrigo Vivi To: Maarten Lankhorst To: Maxime Ripard To: Thomas Zimmermann To: David Airlie To: Daniel Vetter To: William Hubbs To: Chris Brannon To: Kirk Reiser To: Samuel Thibault To: Paul Moore To: Stephen Smalley To: Ondrej Mosnacek To: Catalin Marinas To: Will Deacon To: Marc Zyngier To: Oliver Upton To: James Morse To: Suzuki K Poulose To: Zenghui Yu To: Greg Kroah-Hartman To: Jiri Slaby To: Nick Desaulniers To: Bill Wendling To: Justin Stitt Cc: linux-kernel@vger.kernel.org Cc: linux-kbuild@vger.kernel.org Cc: intel-xe@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Cc: speakup@linux-speakup.org Cc: selinux@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: kvmarm@lists.linux.dev Cc: linux-serial@vger.kernel.org Cc: llvm@lists.linux.dev Cc: Finn Behrens Cc: Daniel Gomez (Samsung) Cc: gost.dev@samsung.com Signed-off-by: Daniel Gomez --- Daniel Gomez (11): kbuild: add header_install dependency to scripts file2alias: fix uuid_t definitions for macos drm/xe: xe_gen_wa_oob: fix program_invocation_short_name for macos accessiblity/speakup: genmap and makemapdata require linux/version.h selinux/genheaders: include bitsperlong and posix_types headers selinux/mdp: include bitsperlong and posix_types headers include: add elf.h support include: add endian.h support scripts/mod: add byteswap support tty/vt: conmakehash requires linux/limits.h scripts/kallsyms: add compatibility support for macos Nick Desaulniers (1): scripts: subarch.include: fix SUBARCH on MacOS hosts Makefile | 2 +- arch/arm64/kernel/pi/Makefile | 1 + arch/arm64/kernel/vdso32/Makefile | 1 + arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- drivers/accessibility/speakup/Makefile | 2 + drivers/gpu/drm/xe/xe_gen_wa_oob.c | 8 +- drivers/tty/vt/Makefile | 1 + include/byteswap/byteswap.h | 35 + include/elf/elf.h | 4491 ++++++++++++++++++++++++++++++++ include/endian/bits/uintn-identity.h | 48 + include/endian/endian.h | 63 + scripts/Makefile | 3 +- scripts/kallsyms.c | 4 + scripts/mod/Makefile | 6 + scripts/mod/file2alias.c | 3 + scripts/selinux/genheaders/Makefile | 3 +- scripts/selinux/mdp/Makefile | 3 +- scripts/subarch.include | 3 +- 18 files changed, 4672 insertions(+), 7 deletions(-) --- base-commit: 1e391b34f6aa043c7afa40a2103163a0ef06d179 change-id: 20240807-macos-build-support-9ca0d77adb17 Best regards,