diff --git a/.github/workflows/abidiff.yml b/.github/workflows/abidiff.yml index 323e6f7733..94a3d6856f 100644 --- a/.github/workflows/abidiff.yml +++ b/.github/workflows/abidiff.yml @@ -11,13 +11,20 @@ on: jobs: run-abidiff: name: Compare ABIs - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 + container: + image: ghcr.io/managarm/mlibc-crossers:latest + defaults: + run: + shell: bash steps: - name: Install prerequisites run: | - sudo apt-get install ninja-build g++-10 abigail-tools - sudo pip3 install setuptools - sudo pip3 install meson xbstrap + apt-get update + apt-get install -y ninja-build qemu-user \ + python3-setuptools python3-jsonschema \ + python3-pip abigail-tools + pip install -U xbstrap pyexpect meson - name: Checkout base branch if: ${{ github.base_ref }} @@ -56,41 +63,59 @@ jobs: - name: Set up linux kernel headers run: | - mkdir -p linux-headers-base/{src,build} - cp mlibc-base/ci/bootstrap.yml linux-headers-base/src/ - ( - cd linux-headers-base/build - xbstrap init ../src - xbstrap install linux-headers - ) - mkdir -p linux-headers-branch/{src,build} - cp mlibc-branch/ci/bootstrap.yml linux-headers-branch/src/ - ( - cd linux-headers-branch/build - xbstrap init ../src - xbstrap install linux-headers - ) - cat > linux-headers-base/build/bootstrap-site.yml << EOF - define_options: - arch: ${{matrix.arch}} - EOF - cp linux-headers-base/build/bootstrap-site.yml linux-headers-branch/build/bootstrap-site.yml + set -x + mkdir -p linux-headers-base/{src,build} + cp mlibc-base/ci/bootstrap.yml linux-headers-base/src/ + ( + cd linux-headers-base/build + xbstrap init ../src + xbstrap install linux-headers + ) + mkdir -p linux-headers-branch/{src,build} + cp mlibc-branch/ci/bootstrap.yml linux-headers-branch/src/ + ( + cd linux-headers-branch/build + xbstrap init ../src + xbstrap install linux-headers + ) + cat > linux-headers-base/build/bootstrap-site.yml << EOF + define_options: + arch: ${{matrix.arch}} + EOF + cp linux-headers-base/build/bootstrap-site.yml linux-headers-branch/build/bootstrap-site.yml - name: Build and install both copies run: | set -xe - export C=gcc-10 CXX=g++-10 mkdir root-base root-branch + cat > linux-x86_64.cross-file <<-EOF + [binaries] + c = ['x86_64-linux-mlibc-gcc'] + cpp = ['x86_64-linux-mlibc-g++'] + + [host_machine] + system = 'linux' + cpu_family = 'x86_64' + cpu = 'x86_64' + endian = 'little' + EOF ( cd mlibc-branch - meson --buildtype=debugoptimized -Dlinux_kernel_headers=$GITHUB_WORKSPACE/linux-headers-branch/build/packages/linux-headers/usr/include build + meson setup \ + --cross-file=../linux-x86_64.cross-file \ + --buildtype=debugoptimized \ + -Dlinux_kernel_headers=$GITHUB_WORKSPACE/linux-headers-branch/build/packages/linux-headers/usr/include \ + build ninja -C build DESTDIR="$GITHUB_WORKSPACE/root-branch" ninja -C build install ) ( cd mlibc-base - # defaults to all features, linux build - meson --buildtype=debugoptimized -Dlinux_kernel_headers=$GITHUB_WORKSPACE/linux-headers-base/build/packages/linux-headers/usr/include build + meson setup \ + --cross-file=../linux-x86_64.cross-file \ + --buildtype=debugoptimized \ + -Dlinux_kernel_headers=$GITHUB_WORKSPACE/linux-headers-branch/build/packages/linux-headers/usr/include \ + build ninja -C build DESTDIR="$GITHUB_WORKSPACE/root-base" ninja -C build install ) @@ -98,6 +123,7 @@ jobs: run: | # TODO(arsen): does this require handling for version suffixes? set -e +x + exec 2>&1 # work around GHA foolishly decoupling stdout and stderr exitcode=0 git -C mlibc-branch show -s --format=%s | grep -q abi-break || \ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3acc6a7aa2..c31659b9dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,18 +9,17 @@ jobs: arch: [x86_64, riscv64, aarch64] builds: [mlibc, mlibc-static, mlibc-shared, mlibc-ansi-only, mlibc-headers-only] name: Build mlibc - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 + container: + image: ghcr.io/managarm/mlibc-crossers:latest steps: - name: Install prerequisites - # Note: the default jsonschema is too old. - # xbstrap should fix this by demanding a recent version. run: | - sudo apt-get update - sudo apt-get install ninja-build g++-10 g++-10-riscv64-linux-gnu g++-10-aarch64-linux-gnu qemu-user - sudo pip3 install setuptools - sudo pip3 install -U jsonschema - sudo pip3 install meson xbstrap - sudo pip3 install pyexpect + apt-get update + apt-get install -y ninja-build qemu-user \ + python3-setuptools python3-jsonschema \ + python3-pexpect python3-pip netbase + pip install -U xbstrap pyexpect meson - name: Prepare directories run: | mkdir src/ @@ -49,26 +48,23 @@ jobs: - name: Test mlibc run: 'meson test -v -C pkg-builds/${{matrix.builds}}' working-directory: build/ - - name: Build GCC - if: ${{matrix.builds == 'mlibc' && matrix.arch == 'x86_64'}} - run: 'xbstrap install-tool gcc' - working-directory: build/ compile-sysdeps: strategy: matrix: sysdeps: [dripos, lemon, aero, ironclad, lyre, keyronex] name: Compile sysdeps - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 + container: + image: ghcr.io/managarm/mlibc-crossers:latest steps: - name: Install prerequisites - # Note: the default jsonschema is too old. - # xbstrap should fix this by demanding a recent version. run: | - sudo apt-get install ninja-build g++-10 - sudo pip3 install setuptools - sudo pip3 install -U jsonschema - sudo pip3 install meson xbstrap + apt-get update + apt-get install -y ninja-build qemu-user \ + python3-setuptools python3-jsonschema \ + python3-pip + pip install -U xbstrap meson - name: Checkout uses: actions/checkout@v2 with: @@ -85,8 +81,8 @@ jobs: - name: Compile sysdeps run: | meson setup \ - "-Dc_args=['-fno-stack-protector', '-U__linux__']" \ - "-Dcpp_args=['-fno-stack-protector', '-U__linux__']" \ + "-Dc_args=['-fno-stack-protector', '-U__linux__', '-Wno-error=maybe-uninitialized']" \ + "-Dcpp_args=['-fno-stack-protector', '-U__linux__', '-Wno-error=maybe-uninitialized']" \ "-Dbuild_tests=true" \ "-Db_sanitize=undefined" \ "-Dlinux_kernel_headers=$(pwd)/packages/linux-headers/usr/include" \ diff --git a/ci/aero.cross-file b/ci/aero.cross-file index 9e3023f39c..48772eb220 100644 --- a/ci/aero.cross-file +++ b/ci/aero.cross-file @@ -1,6 +1,6 @@ [binaries] -c = 'gcc-10' -cpp = 'g++-10' +c = 'x86_64-linux-mlibc-gcc' +cpp = 'x86_64-linux-mlibc-g++' [properties] needs_exe_wrapper = true diff --git a/ci/bootstrap.yml b/ci/bootstrap.yml index 38eb78fca1..88db3b8b0b 100644 --- a/ci/bootstrap.yml +++ b/ci/bootstrap.yml @@ -3,13 +3,6 @@ declare_options: default: x86_64 sources: - - name: gcc - git: 'git://gcc.gnu.org/git/gcc.git' - tag: 'releases/gcc-10.3.0' - regenerate: - - args: ['./contrib/download_prerequisites'] - workdir: '@THIS_SOURCE_DIR@' - - name: mlibc git: 'https://github.com/managarm/mlibc.git' branch: 'master' @@ -21,53 +14,6 @@ sources: version: '6.1.8' tools: - - name: gcc - from_source: gcc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - - '--program-prefix=mlibc-' - - '--with-sysroot=@SYSROOT_DIR@' - - '--enable-languages=c,c++' - - '--disable-multilib' - - '--disable-bootstrap' - - '--disable-libgomp' - - '--with-specs=%{!static:%x{-rpath=@SYSROOT_DIR@/usr/lib} %x{-dynamic-linker=@SYSROOT_DIR@/usr/lib/ld.so}}' - # -g blows up GCC's binary size. - - 'CFLAGS=-O2' - - 'CXXFLAGS=-O2' - environ: - C: 'gcc-10' - CXX: 'g++-10' - stages: - - name: compiler - pkgs_required: - - mlibc - - linux-headers - compile: - # GCC complains if the include directory is non-existant. - - args: ['mkdir', '-p', '@SYSROOT_DIR@/usr/include'] - - args: ['make', '-j@PARALLELISM@', 'all-gcc'] - install: - - args: ['make', 'install-gcc'] - - name: libgcc - tools_required: - - tool: gcc - stage_dependencies: [compiler] - compile: - - args: ['make', '-j@PARALLELISM@', 'all-target-libgcc'] - install: - - args: ['make', 'install-target-libgcc'] - # TODO: libstdc++ requires some patching before it will work. - # - name: libstdc++ - # tools_required: - # - tool: gcc - # stage_dependencies: [libgcc] - # compile: - # - args: ['make', '-j@PARALLELISM@', 'all-target-libstdc++-v3'] - # install: - # - args: ['make', 'install-target-libstdc++-v3'] packages: - name: mlibc @@ -81,6 +27,8 @@ packages: - '--prefix=/usr' - '--libdir=lib' - '--buildtype=debugoptimized' + - "-Dc_args=['-Wno-error=maybe-uninitialized']" + - "-Dcpp_args=['-Wno-error=maybe-uninitialized']" - "-Dbuild_tests=true" - "-Db_sanitize=undefined" - "-Ddefault_library=both" @@ -88,6 +36,9 @@ packages: - '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include' - "--cross-file=@THIS_SOURCE_DIR@/ci/linux-@OPTION:arch@.cross-file" - '@THIS_SOURCE_DIR@' + environ: + CFLAGS: '-Wno-error=maybe-uninitialized' + CXXFLAGS: '-Wno-error=maybe-uninitialized' build: - args: ['ninja'] - args: ['ninja', 'install'] @@ -106,6 +57,8 @@ packages: - '--prefix=/usr' - '--libdir=lib' - '--buildtype=debugoptimized' + - "-Dc_args=['-Wno-error=maybe-uninitialized']" + - "-Dcpp_args=['-Wno-error=maybe-uninitialized']" - "-Dbuild_tests=true" - "-Db_sanitize=undefined" - "-Ddefault_library=static" @@ -130,6 +83,8 @@ packages: - '--prefix=/usr' - '--libdir=lib' - '--buildtype=debugoptimized' + - "-Dc_args=['-Wno-error=maybe-uninitialized']" + - "-Dcpp_args=['-Wno-error=maybe-uninitialized']" - "-Dbuild_tests=true" - "-Db_sanitize=undefined" - "-Ddefault_library=shared" @@ -155,6 +110,8 @@ packages: - '--prefix=/usr' - '--libdir=lib' - '--buildtype=debugoptimized' + - "-Dc_args=['-Wno-error=maybe-uninitialized']" + - "-Dcpp_args=['-Wno-error=maybe-uninitialized']" - "-Dbuild_tests=true" - "-Db_sanitize=undefined" - "-Ddefault_library=both" @@ -184,6 +141,8 @@ packages: - '--prefix=/usr' - '--libdir=lib' - '--buildtype=debugoptimized' + - "-Dc_args=['-Wno-error=maybe-uninitialized']" + - "-Dcpp_args=['-Wno-error=maybe-uninitialized']" - "-Db_sanitize=undefined" - "-Dwerror=true" - "-Dheaders_only=true" diff --git a/ci/dripos.cross-file b/ci/dripos.cross-file index bc7dcdb9db..6a79be9e33 100644 --- a/ci/dripos.cross-file +++ b/ci/dripos.cross-file @@ -1,6 +1,6 @@ [binaries] -c = 'gcc-10' -cpp = 'g++-10' +c = 'x86_64-linux-mlibc-gcc' +cpp = 'x86_64-linux-mlibc-g++' [properties] needs_exe_wrapper = true diff --git a/ci/ironclad.cross-file b/ci/ironclad.cross-file index 2a643ff03f..f016592c7b 100644 --- a/ci/ironclad.cross-file +++ b/ci/ironclad.cross-file @@ -1,6 +1,6 @@ [binaries] -c = 'gcc-10' -cpp = 'g++-10' +c = 'x86_64-linux-mlibc-gcc' +cpp = 'x86_64-linux-mlibc-g++' [properties] needs_exe_wrapper = true diff --git a/ci/keyronex.cross-file b/ci/keyronex.cross-file index b5e82a4812..d77a54046d 100644 --- a/ci/keyronex.cross-file +++ b/ci/keyronex.cross-file @@ -1,6 +1,6 @@ [binaries] -c = ['gcc-10'] -cpp = ['g++-10'] +c = ['x86_64-linux-mlibc-gcc'] +cpp = ['x86_64-linux-mlibc-g++'] [host_machine] system = 'keyronex' diff --git a/ci/lemon.cross-file b/ci/lemon.cross-file index f0232bc761..23dcf7e3ff 100644 --- a/ci/lemon.cross-file +++ b/ci/lemon.cross-file @@ -1,6 +1,6 @@ [binaries] -c = 'gcc-10' -cpp = 'g++-10' +c = 'x86_64-linux-mlibc-gcc' +cpp = 'x86_64-linux-mlibc-g++' [properties] needs_exe_wrapper = true diff --git a/ci/linux-aarch64.cross-file b/ci/linux-aarch64.cross-file index dac9a362af..f1843ae38c 100644 --- a/ci/linux-aarch64.cross-file +++ b/ci/linux-aarch64.cross-file @@ -2,8 +2,8 @@ skip_sanity_check = true [binaries] -c = ['aarch64-linux-gnu-gcc-10'] -cpp = ['aarch64-linux-gnu-g++-10'] +c = ['aarch64-linux-mlibc-gcc'] +cpp = ['aarch64-linux-mlibc-g++'] exe_wrapper = 'qemu-aarch64' [host_machine] diff --git a/ci/linux-riscv64.cross-file b/ci/linux-riscv64.cross-file index 42f120c159..283eaf2a69 100644 --- a/ci/linux-riscv64.cross-file +++ b/ci/linux-riscv64.cross-file @@ -2,8 +2,8 @@ skip_sanity_check = true [binaries] -c = ['riscv64-linux-gnu-gcc-10'] -cpp = ['riscv64-linux-gnu-g++-10'] +c = ['riscv64-linux-mlibc-gcc'] +cpp = ['riscv64-linux-mlibc-g++'] exe_wrapper = 'qemu-riscv64' [host_machine] diff --git a/ci/linux-x86_64.cross-file b/ci/linux-x86_64.cross-file index 47954d410d..fdf2b2d456 100644 --- a/ci/linux-x86_64.cross-file +++ b/ci/linux-x86_64.cross-file @@ -1,6 +1,6 @@ [binaries] -c = ['gcc-10'] -cpp = ['g++-10'] +c = ['x86_64-linux-mlibc-gcc'] +cpp = ['x86_64-linux-mlibc-g++'] [host_machine] system = 'linux' diff --git a/ci/lyre.cross-file b/ci/lyre.cross-file index 80fb55b8e7..1d4cd70d13 100644 --- a/ci/lyre.cross-file +++ b/ci/lyre.cross-file @@ -1,6 +1,6 @@ [binaries] -c = 'gcc-10' -cpp = 'g++-10' +c = 'x86_64-linux-mlibc-gcc' +cpp = 'x86_64-linux-mlibc-g++' [properties] needs_exe_wrapper = true diff --git a/meson.build b/meson.build index 1bb7c66642..524350cebe 100644 --- a/meson.build +++ b/meson.build @@ -43,7 +43,9 @@ internal_conf = configuration_data() mlibc_conf = configuration_data() if not headers_only - cxxshim_dep = dependency('cxxshim', fallback: ['cxxshim', 'cxxshim_dep']) + cxxshim_dep = dependency('cxxshim', + required: false, + fallback: ['cxxshim', 'cxxshim_dep']) libc_deps += cxxshim_dep rtdl_deps += cxxshim_dep @@ -57,6 +59,7 @@ if not headers_only add_languages('c', 'cpp') c_compiler = meson.get_compiler('c') + cpp_compiler = meson.get_compiler('cpp') add_project_arguments('-Wno-unused-function', '-D__MLIBC_BUILDING_MLIBC', language: ['c', 'cpp']) add_project_arguments('-nostdinc', '-fno-builtin', language: ['c', 'cpp']) @@ -92,6 +95,56 @@ if not headers_only rtdl_include_dirs += include_directories(ccdir / 'include') libc_include_dirs += include_directories(ccdir / 'include') + + cplusplus_include_path = [] + + c_output = run_command(c_compiler.cmd_array(), '-E', '-v', '-x', 'c', + '/dev/null', '-o', '-', + capture: true, + check: true).stderr().split('\n') + + cpp_output = run_command(cpp_compiler.cmd_array(), '-E', '-v', '-x', + 'c++', '/dev/null', '-o', '-', + capture: true, + check: true).stderr().split('\n') + + c_relevant_lines = [] + + relevantmarker = '#include <...>' + relevant_started = false + + foreach line : c_output + if relevant_started + if not line.startswith(' ') + break + endif + c_relevant_lines += line.strip() + elif line.startswith(relevantmarker) + relevant_started = true + endif + endforeach + + relevant_started = false + + foreach line : cpp_output + if relevant_started + if not line.startswith(' ') + break + endif + debug('maybe relevant', line) + stripped = line.strip() + if stripped in c_relevant_lines + debug('not relevant (is C)', line) + continue + endif + cplusplus_include_path += include_directories(stripped) + elif line.startswith(relevantmarker) + relevant_started = true + endif + endforeach + + rtdl_include_dirs += cplusplus_include_path + libc_include_dirs += cplusplus_include_path endif internal_conf.set_quoted('MLIBC_SYSTEM_NAME', host_machine.system()) @@ -111,16 +164,18 @@ if host_machine.system() == 'linux' rtdl_include_dirs += include_directories('sysdeps/linux/include') libc_include_dirs += include_directories('sysdeps/linux/include') - if get_option('linux_kernel_headers') == '' - error('linux_kernel_headers is not set') - endif + if not headers_only + if get_option('linux_kernel_headers') == '' + error('linux_kernel_headers is not set') + endif - if not import('fs').is_dir(get_option('linux_kernel_headers')) - error('linux_kernel_headers is not set to a valid path') - endif + if not import('fs').is_dir(get_option('linux_kernel_headers')) + error('linux_kernel_headers is not set to a valid path') + endif - rtdl_include_dirs += include_directories(get_option('linux_kernel_headers')) - libc_include_dirs += include_directories(get_option('linux_kernel_headers')) + rtdl_include_dirs += include_directories(get_option('linux_kernel_headers')) + libc_include_dirs += include_directories(get_option('linux_kernel_headers')) + endif internal_conf.set10('MLIBC_MAP_DSO_SEGMENTS', true) internal_conf.set10('MLIBC_MMAP_ALLOCATE_DSO', true) @@ -201,12 +256,14 @@ if not disable_intl_option endif if not disable_linux_option - if get_option('linux_kernel_headers') == '' - error('linux_kernel_headers is not set') - endif + if not headers_only + if get_option('linux_kernel_headers') == '' + error('linux_kernel_headers is not set') + endif - if not import('fs').is_dir(get_option('linux_kernel_headers')) - error('linux_kernel_headers is not set to a valid path') + if not import('fs').is_dir(get_option('linux_kernel_headers')) + error('linux_kernel_headers is not set to a valid path') + endif endif rtdl_include_dirs += include_directories('options/linux/include') diff --git a/options/posix/generic/lookup.cpp b/options/posix/generic/lookup.cpp index d592feec66..f877fe5419 100644 --- a/options/posix/generic/lookup.cpp +++ b/options/posix/generic/lookup.cpp @@ -141,7 +141,7 @@ int lookup_name_dns(struct lookup_result &buf, const char *name, buf.buf.push(std::move(buffer)); break; case RECORD_CNAME: - canon_name = std::move(read_dns_name(response, it)); + canon_name = read_dns_name(response, it); buf.aliases.push(std::move(dns_name)); break; default: diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp index a0f2bf58b8..973cfbbb52 100644 --- a/options/rtdl/generic/linker.cpp +++ b/options/rtdl/generic/linker.cpp @@ -554,8 +554,6 @@ void ObjectRepository::_fetchFromFile(SharedObject *object, int fd) { // -------------------------------------------------------- void ObjectRepository::_parseDynamic(SharedObject *object) { - static bool rpathWarned = false; - if(!object->dynamic) mlibc::infoLogger() << "ldso: Object '" << object->name << "' does not have a dynamic section" << frg::endlog; @@ -564,6 +562,8 @@ void ObjectRepository::_parseDynamic(SharedObject *object) { // Fix up these offsets to addresses after the loop, since the // addresses depend on the value of DT_STRTAB. frg::optional runpath_offset; + /* If true, ignore the RPATH. */ + bool runpath_found = false; frg::optional soname_offset; for(size_t i = 0; object->dynamic[i].d_tag != DT_NULL; i++) { @@ -648,12 +648,13 @@ void ObjectRepository::_parseDynamic(SharedObject *object) { << frg::endlog; break; case DT_RPATH: - if(!rpathWarned) { - rpathWarned = true; - mlibc::infoLogger() << "\e[31mrtdl: RUNPATH not preferred over RPATH properly\e[39m" << frg::endlog; + if (runpath_found) { + /* Ignore RPATH if RUNPATH was present. */ + break; } [[fallthrough]]; case DT_RUNPATH: + runpath_found = dynamic->d_tag == DT_RUNPATH; runpath_offset = dynamic->d_un.d_val; break; case DT_INIT: diff --git a/sysdeps/managarm/aarch64/crt-src/crti.S b/sysdeps/managarm/aarch64/crt-src/crti.S new file mode 100644 index 0000000000..4307dfb6b4 --- /dev/null +++ b/sysdeps/managarm/aarch64/crt-src/crti.S @@ -0,0 +1,15 @@ + .ident "aarch64-managarm-mlibc crti" + + .section .init + .global _init +_init: + stp x29, x30, [sp, -16]! + mov x29, sp + + .section .fini + .global _fini +_fini: + stp x29, x30, [sp, -16]! + mov x29, sp + + .section .note.GNU-stack,"",%progbits diff --git a/sysdeps/managarm/aarch64/crt-src/crtn.S b/sysdeps/managarm/aarch64/crt-src/crtn.S new file mode 100644 index 0000000000..005d8702ab --- /dev/null +++ b/sysdeps/managarm/aarch64/crt-src/crtn.S @@ -0,0 +1,11 @@ + .ident "aarch64-managarm-mlibc crtn" + + .section .init + ldp x29, x30, [sp], #16 + ret + + .section .fini + ldp x29, x30, [sp], #16 + ret + + .section .note.GNU-stack,"",%progbits diff --git a/sysdeps/managarm/meson.build b/sysdeps/managarm/meson.build index 671f180905..34da8d77c5 100644 --- a/sysdeps/managarm/meson.build +++ b/sysdeps/managarm/meson.build @@ -117,25 +117,27 @@ if not no_headers endif if not headers_only - crt_src = files(host_machine.cpu_family() / 'crt-src/crt0.S') - crt = custom_target('crt0', - build_by_default: true, - command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], - input: crt_src, - output: 'crt0.o', - install: true, - install_dir: get_option('libdir') - ) - - if host_machine.cpu_family() == 'x86_64' - crt_pie = custom_target('Scrt1', + crtstuff = ['crt0'] + if host_machine.cpu_family() in ['x86_64', 'aarch64'] + crtstuff += [ + 'Scrt1', + 'crti', + 'crtn' + ] + endif + foreach crtthing : crtstuff + crtf = crtthing + '.S' + crt_src = files(host_machine.cpu_family() / 'crt-src' / crtf) + crt = custom_target( + crtthing, build_by_default: true, - command: c_compiler.cmd_array() + ['-fPIE', '-c', '-o', '@OUTPUT@', '@INPUT@'], - input: 'x86_64/crt-src/Scrt1.S', - output: 'Scrt1.o', + command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], + input: crt_src, + output: crtthing + '.o', install: true, install_dir: get_option('libdir') ) - endif + endforeach + endif diff --git a/sysdeps/managarm/x86_64/crt-src/crti.S b/sysdeps/managarm/x86_64/crt-src/crti.S new file mode 100644 index 0000000000..889b2a5090 --- /dev/null +++ b/sysdeps/managarm/x86_64/crt-src/crti.S @@ -0,0 +1,13 @@ + .ident "x86_64-managarm-mlibc crti" + + .section .init + .globl _init + .type _init,@function +_init: + + .section .fini + .globl _fini + .type _fini,@function +_fini: + +.section .note.GNU-stack,"",%progbits diff --git a/sysdeps/managarm/x86_64/crt-src/crtn.S b/sysdeps/managarm/x86_64/crt-src/crtn.S new file mode 100644 index 0000000000..1b2ca89f03 --- /dev/null +++ b/sysdeps/managarm/x86_64/crt-src/crtn.S @@ -0,0 +1,9 @@ + .ident "x86_64-managarm-mlibc crtn" + + .section .init + ret + + .section .fini + ret + + .section .note.GNU-stack,"",%progbits diff --git a/tests/glibc/error.py b/tests/glibc/error.py index 77d4357c41..38339741ba 100644 --- a/tests/glibc/error.py +++ b/tests/glibc/error.py @@ -1,7 +1,11 @@ import subprocess import sys +import os from pyexpect import expect -output = subprocess.check_output([sys.argv[1]], stderr=subprocess.STDOUT) +wrapper = os.getenv("MESON_EXE_WRAPPER") +wrapper = [x for x in (wrapper,) if x] + +output = subprocess.check_output(wrapper + [sys.argv[1]], stderr=subprocess.STDOUT) expect(bytes(sys.argv[1], 'utf-8') + b': test: error: Invalid argument (EINVAL)\n').to_equal(output) diff --git a/tests/glibc/error_at_line.py b/tests/glibc/error_at_line.py index 69b7d13f24..7499e0554c 100644 --- a/tests/glibc/error_at_line.py +++ b/tests/glibc/error_at_line.py @@ -1,7 +1,11 @@ import subprocess import sys +import os from pyexpect import expect -output = subprocess.check_output([sys.argv[1]], stderr=subprocess.STDOUT) +wrapper = os.getenv("MESON_EXE_WRAPPER") +wrapper = [x for x in (wrapper,) if x] + +output = subprocess.check_output(wrapper + [sys.argv[1]], stderr=subprocess.STDOUT) expect(bytes(sys.argv[1], 'utf-8') + b':error_at_line:5: test: error: Invalid argument (EINVAL)\n').to_equal(output) diff --git a/tests/meson.build b/tests/meson.build index f8f5e40c78..e1d747b128 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -127,6 +127,7 @@ host_libc_noasan_test_cases = [ 'posix/posix_memalign', 'posix/search', # requires tdelete (#351) 'ansi/calloc', # does some overflowing + 'linux/pthread_attr', # encounters memory leaks ] extra_cflags_test_cases = {