Skip to content

Commit

Permalink
Various arm64 and bootstrap-on-FreeBSD fixes (#427)
Browse files Browse the repository at this point in the history
* comment out conflicting define

* add msgSendv for aarch64 from Zoe

* Fix arm64 build after llvm 18.1.3 upgrade

Apparently clang 18 has become more strict about using floating point
registers in inline assembly when -mgeneral-regs-only is used. This
causes sys/arm64/arm64/vfp.c to fail to compile, with "error:
instruction requires: fp-armv8", and "error: expected readable system
register".

To fix it, similar to other files compiled for arm64, disable
-mgeneral-regs-only for this particular file.

PR:		276104
MFC after:	1 month

(cherry picked from commit f4d93b6)

* bump to libpng 1.6.43

* disable NEON in libpixman

* neon is apparently broken (it's disabled even in upstream ports)
* dunno if `-DPIXMAN_TIMERS` is important, but had to turn it off

* use MACHINE_ARCH rather than MACHINE in zsh build

* skip intel files on arm64

* make sure PATH is set to find bootstrapped python3

* disable some mesa drivers that make linux assumptions

* install is called anyway, put the symlinks in there

* fix mesa build on arm

* don't build docs

---------

Co-authored-by: Dimitry Andric <[email protected]>
  • Loading branch information
RangerRick and DimitryAndric authored May 14, 2024
1 parent 4a0a6fe commit 57fe032
Show file tree
Hide file tree
Showing 300 changed files with 20,928 additions and 16,106 deletions.
7 changes: 2 additions & 5 deletions Frameworks/AppKit/gperf/configure
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ enable_option_checking
ac_precious_vars='build_alias
host_alias
target_alias'
ac_subdirs_all='lib src tests doc'
ac_subdirs_all='lib src tests'

# Initialize some variables set by options.
ac_init_help=
Expand Down Expand Up @@ -1729,7 +1729,7 @@ fi



subdirs="$subdirs lib src tests doc"
subdirs="$subdirs lib src tests"


extrasub="$extrasub"'
Expand All @@ -1744,9 +1744,6 @@ p
g
s/@subdir@/tests/
p
g
s/@subdir@/doc/
p
d
}
'
Expand Down
3 changes: 2 additions & 1 deletion Frameworks/Foundation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,8 @@ LDFLAGS+= ${FMWK_LDFLAGS} \

.if ${MACHINE_CPUARCH} == "aarch64"
CFLAGS += -DCOCOTRON_DISALLOW_FORWARDING=1
SRCS += NSObject/objc_msg_sendv-Disabled.m
# SRCS += NSObject/objc_msg_sendv-Disabled.m
SRCS += NSObject/platform_linux/msgSendv-aarch64.s
.elif ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
SRCS += NSObject/platform_linux/msgSendv-x64.s
.endif
Expand Down
35 changes: 35 additions & 0 deletions Frameworks/Foundation/NSObject/platform_linux/msgSendv-aarch64.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.section .text

.global _objc_msgSendv

_objc_msgSendv:
// Prologue
stp x29, x30, [sp, #-16]! // Save frame pointer and link register
mov x29, sp // Set up frame pointer

// Save callee-saved registers
stp x19, x20, [sp, #0] // Save x19 and x20
stp x21, x22, [sp, #16] // Save x21 and x22
stp x23, x24, [sp, #32] // Save x23 and x24
stp x25, x26, [sp, #48] // Save x25 and x26
stp x27, x28, [sp, #64] // Save x27 and x28

// Move the method pointer (selector) into x0
mov x0, x1 // Assuming the selector is passed in x1

// Move the receiver object pointer into x19
mov x19, x2 // Assuming the receiver object pointer is passed in x2

// Call objc_msg_lookup() to get the IMP (method implementation pointer)
bl _objc_msg_lookup

// Restore callee-saved registers
ldp x19, x20, [sp, #0] // Restore x19 and x20
ldp x21, x22, [sp, #16] // Restore x21 and x22
ldp x23, x24, [sp, #32] // Restore x23 and x24
ldp x25, x26, [sp, #48] // Restore x25 and x26
ldp x27, x28, [sp, #64] // Restore x27 and x28

// Epilogue
ldp x29, x30, [sp], #16 // Restore frame pointer and link register
ret // Return from function
12 changes: 10 additions & 2 deletions Frameworks/OpenGL/libdrm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ PACKAGE= lib${LIB}
SHLIB_MAJOR= 2

SRCS= ${LIBDRM_FILES} ${LIBDRM_NOUVEAU_FILES} ${LIBDRM_AMDGPU_FILES}
SRCS+= ${LIBDRM_RADEON_FILES} ${LIBDRM_INTEL_FILES}
SRCS+= ${LIBDRM_RADEON_FILES}

.if ${.TARGET} == "amd64" || ${.TARGET} == "i386"
SRCS+= ${LIBDRM_INTEL_FILES}
.endif

INCSDIR= ${INCLUDEDIR}/${PACKAGE}
INCS=
CFLAGS+= -I${.CURDIR}/include/drm -I${.CURDIR} \
Expand All @@ -26,7 +31,6 @@ CFLAGS+= -I${.CURDIR}/include/drm -I${.CURDIR} \
-DHAVE_SYS_SYSCTL_H \
-DHAVE_OPEN_MEMSTREAM \
-DHAVE_VISIBILITY \
-DHAVE_INTEL \
-DHAVE_RADEON \
-DHAVE_VMWGFX \
-DHAVE_VC4 \
Expand All @@ -38,6 +42,10 @@ CFLAGS+= -I${.CURDIR}/include/drm -I${.CURDIR} \
-Wno-error=gnu-variable-sized-type-not-at-end \
-Wno-error=\#warnings

.if ${.TARGET} == "amd64" || ${.TARGET} == "i386"
CFLAGS+= -DHAVE_INTEL
.endif

LDFLAGS+= -L${MAKEOBJDIR}/../libpciaccess -lpciaccess -Wl,-R\$$ORIGIN/Resources

WARNS?= 2
Expand Down
5 changes: 3 additions & 2 deletions Frameworks/OpenGL/mesa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CFLAGS+= -I${.CURDIR}/../libdrm/nouveau
CFLAGS+= -I${.CURDIR}/../libdrm/radeon
CFLAGS+= -I${.CURDIR}/../libdrm/intel
CFLAGS+= -I${.CURDIR}/../libdrm/include/drm
CFLAGS+= -Wno-format -Wno-asm-operand-widths

LDFLAGS= -L${MAKEOBJDIR}/../wayland/src -lwayland
LDFLAGS+= -L${MAKEOBJDIR}/../libdrm -ldrm
Expand All @@ -26,7 +27,7 @@ all: build
build:
LD_LIBRARY_PATH=${OBJTOP}/tmp/usr/lib:${OBJTOP}/Frameworks/OpenGL/libpciaccess \
PYTHONPATH=${OBJTOP}/tmp/usr/lib/python3.10 \
PATH=${OBJTOP}/tmp/usr/bin:${OBJTOP}/tmp/legacy/bin:${OBJTOP}/Frameworks/OpenGL/wayland/scanner:${PATH} \
PATH=${OBJTOP}/tmp/usr/bin:${OBJTOP}/tmp/legacy/bin:${OBJTOP}/Frameworks/OpenGL/wayland/scanner:$${PATH} \
${MESON} setup --reconfigure -Dprefix=${PREFIX} -Dplatforms=wayland \
-DSRCTOP=${SRCTOP} -Dc_args="${CFLAGS}" -Dcpp_args="${CFLAGS}" \
-Dc_link_args="${LDFLAGS}" -Dcpp_link_args="${LDFLAGS}" \
Expand All @@ -38,7 +39,7 @@ build:
-Dgbm=enabled -Dxmlconfig=disabled -Dexpat=disabled \
${MAKEOBJDIR} ${.CURDIR}
sed -i.bak -e 's@-I/usr/include@@g' ${MAKEOBJDIR}/build.ninja
PATH=${OBJTOP}/tmp/usr/bin:${OBJTOP}/tmp/legacy/bin:${OBJTOP}/Frameworks/OpenGL/wayland/scanner:${OBJTOP}/usr.bin/clang/llvm-ar \
PATH=${OBJTOP}/tmp/usr/bin:${OBJTOP}/tmp/legacy/bin:${OBJTOP}/Frameworks/OpenGL/wayland/scanner:${OBJTOP}/usr.bin/clang/llvm-ar:$$PATH \
${NINJA}

install:
Expand Down
6 changes: 3 additions & 3 deletions Frameworks/OpenGL/mesa/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ if gallium_drivers.contains('auto')
]
elif ['arm', 'aarch64'].contains(host_machine.cpu_family())
gallium_drivers = [
'v3d', 'vc4', 'freedreno', 'etnaviv', 'nouveau', 'svga',
'vc4', 'etnaviv', 'nouveau', 'svga',
'tegra', 'virgl', 'lima', 'panfrost', 'swrast', 'iris'
]
elif ['mips', 'mips64', 'riscv32', 'riscv64'].contains(host_machine.cpu_family())
Expand Down Expand Up @@ -1110,8 +1110,8 @@ else

# MinGW chokes on format specifiers and I can't get it all working
if not (cc.get_argument_syntax() == 'gcc' and host_machine.system() == 'windows')
_trial_c += ['-Werror=format', '-Wformat-security']
_trial_cpp += ['-Werror=format', '-Wformat-security']
_trial_c += ['-Wformat-security']
_trial_cpp += ['-Wformat-security']
endif

# FreeBSD annotated <pthread.h> but Mesa isn't ready
Expand Down
1 change: 0 additions & 1 deletion Frameworks/OpenGL/mesa/src/microsoft/vulkan/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ if cc.get_argument_syntax() != 'msvc'
'-Werror=unused-variable',
'-Werror=unused-but-set-variable',
'-Werror=unused-value',
'-Werror=format',
'-Werror=switch',
]
dzn_flags += cc.get_supported_arguments(dzn_flags_to_try)
Expand Down
15 changes: 10 additions & 5 deletions lib/libpixman/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,19 @@ SRCS+= \

.if ${MACHINE} == "arm64"
CFLAGS+= \
-DUSE_ARM_SIMD \
-DUSE_ARM_A64_NEON
-UPIXMAN_TIMERS \
-DUSE_ARM_SIMD
SRCS+= \
pixman-arm-neon.c \
pixman-arm-simd.c
.else
CFLAGS+= \
-DPIXMAN_TIMERS
.endif

# add back later:
# -DUSE_ARM_A64_NEON
# pixman-arm-neon.c \
CFLAGS+= \
-DHAVE_ALARM \
-DHAVE_BUILTIN_CLZ \
Expand All @@ -95,11 +101,10 @@ CFLAGS+= \
-DHAVE_LIBPNG \
-DHAVE_PTHREADS \
-DHAVE_FLOAT128 \
-DPIXMAN_TIMERS \
-DSIZEOF_LONG=8

WARNS?= 2
CFLAGS+= -Wno-error=format -Wno-error=expansion-to-defined
CFLAGS+= -Wno-error=format -Wno-error=expansion-to-defined -Wno-error=unknown-attributes

pixman-version.h: pixman/pixman-version.h.in
sed -e "s/@PIXMAN_VERSION_MAJOR@/${MAJOR}/" \
Expand Down
79 changes: 79 additions & 0 deletions lib/libpng/.appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
version: 1.6.x-{build}

branches:
except:
- /libpng[0-1][0-7]/
- /v[0-1][.][0-7][.][0-9]+/

image:
- Visual Studio 2022

shallow_clone: true

environment:
matrix:
- TOOLCHAIN: vstudio
AUTOMATION: cmake
ARCH: x86
- TOOLCHAIN: vstudio
AUTOMATION: cmake
ARCH: x64
- TOOLCHAIN: vstudio
AUTOMATION: cmake
ARCH: arm64
- TOOLCHAIN: llvm
AUTOMATION: cmake
ARCH: x64
- TOOLCHAIN: msys2
AUTOMATION: cmake
ARCH: i686
- TOOLCHAIN: msys2
AUTOMATION: cmake
ARCH: x86_64
- TOOLCHAIN: msys2
AUTOMATION: configure
ARCH: i686
- TOOLCHAIN: msys2
AUTOMATION: configure
ARCH: x86_64
- TOOLCHAIN: msys2
AUTOMATION: makefiles
ARCH: i686
- TOOLCHAIN: msys2
AUTOMATION: makefiles
ARCH: x86_64

install:
- 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe install zlib:%ARCH%-windows'
- 'if "%TOOLCHAIN%"=="vstudio" C:\tools\vcpkg\vcpkg.exe integrate install'
- 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe install zlib:%ARCH%-windows'
- 'if "%TOOLCHAIN%"=="llvm" C:\tools\vcpkg\vcpkg.exe integrate install'

before_build:
- 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_GENERATOR=Visual Studio 17 2022'
- 'if "%TOOLCHAIN%"=="vstudio" set CI_CMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake'
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x86" set CI_CMAKE_GENERATOR_PLATFORM=Win32'
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="x64" set CI_CMAKE_GENERATOR_PLATFORM=x64'
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="arm64" set CI_CMAKE_GENERATOR_PLATFORM=ARM64'
- 'if "%TOOLCHAIN%"=="vstudio" if "%ARCH%"=="arm64" set CI_CMAKE_VARS=-DPNG_TESTS=0'
- 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_GENERATOR=Ninja'
- 'if "%TOOLCHAIN%"=="llvm" set CI_CMAKE_TOOLCHAIN_FILE=C:\tools\vcpkg\scripts\buildsystems\vcpkg.cmake'
- 'if "%TOOLCHAIN%"=="llvm" set CI_CC=clang.exe'
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" set CI_CMAKE_GENERATOR=Unix Makefiles'
- 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="i686" set PATH=C:\msys64\mingw32\bin;%PATH%'
- 'if "%TOOLCHAIN%"=="msys2" if "%ARCH%"=="x86_64" set PATH=C:\msys64\mingw64\bin;%PATH%'
- 'if "%TOOLCHAIN%"=="msys2" set CI_CC=%ARCH%-w64-mingw32-gcc.exe'
- 'set CI_CMAKE_BUILD_FLAGS=-j2'
- 'set CI_CTEST_FLAGS=-j2'
- 'set CI_MAKE_FLAGS=-j2'
- 'set CI_MAKEFILES=scripts/makefile.gcc scripts/makefile.msys scripts/makefile.std'

build_script:
- 'if "%TOOLCHAIN%"=="vstudio" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"'
- 'if "%TOOLCHAIN%"=="llvm" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"'
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"'
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="configure" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_configure.sh"'
- 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="makefiles" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_makefiles.sh"'

cache:
- C:\tools\vcpkg\installed
43 changes: 43 additions & 0 deletions lib/libpng/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# https://editorconfig.org

root = true

[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[*.txt]
indent_style = space

[*.[chS]]
indent_style = space
max_doc_length = 80
max_line_length = 80

[*.dfa]
indent_style = space
max_doc_length = 80
max_line_length = 80

[*.{awk,cmake}]
indent_style = space
max_doc_length = 80
max_line_length = 100

[*.{in,sh}]
indent_style = space
max_doc_length = 100
max_line_length = 100

[{Makefile.in,ltmain.sh}]
indent_style = unset
insert_final_newline = unset
max_doc_length = unset
max_line_length = unset
trim_trailing_whitespace = unset

[COMMIT_EDITMSG]
indent_style = space
max_doc_length = unset
max_line_length = 72
27 changes: 27 additions & 0 deletions lib/libpng/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Linting libpng

on:
push:
branches:
- libpng16
pull_request:
branches:
- libpng16

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Set up the cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/pip.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Install yamllint
run: pip install yamllint
- name: Check out the code
uses: actions/checkout@v4
- name: Run the linting script
run: bash ./ci/ci_lint.sh
Loading

0 comments on commit 57fe032

Please sign in to comment.