Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/linux-premerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ jobs:
target_os: Linux-x86_64
runner: cpullvm-ubuntu24-x86_64

# FIXME: this should maybe go into the nightly instead,
# but I don't want to keep triggering those until we're
# closer to being ready to merge.
- build_script: build_picolibc-v1812_overlay.sh
test_script: test_picolibc-v1812_overlay.sh
target_os: Linux-x86_64
runner: cpullvm-ubuntu24-x86_64

steps:
- name: Checkout source
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
Expand Down
16 changes: 12 additions & 4 deletions qualcomm-software/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ set(LLVM_TOOLCHAIN_C_LIBRARY
"Which C library to use."
)
set_property(CACHE LLVM_TOOLCHAIN_C_LIBRARY
PROPERTY STRINGS picolibc musl-embedded)
PROPERTY STRINGS picolibc picolibc-v1812 musl-embedded)

option(
SHORT_BUILD_PATHS
Expand Down Expand Up @@ -819,9 +819,12 @@ install(
COMPONENT llvm-toolchain-docs
)

if(LLVM_TOOLCHAIN_C_LIBRARY MATCHES "^picolibc")
if(LLVM_TOOLCHAIN_C_LIBRARY STREQUAL picolibc)
string(APPEND LIBC_LICENSE_FILES " - Picolibc: third-party-licenses/COPYING.NEWLIB, third-party-licenses/COPYING.picolibc\n")
endif()
if(LLVM_TOOLCHAIN_C_LIBRARY STREQUAL picolibc-v1812)
string(APPEND LIBC_LICENSE_FILES " - Picolibc: third-party-licenses/COPYING.picolibc\n")
endif()
if(LLVM_TOOLCHAIN_C_LIBRARY STREQUAL musl-embedded OR ENABLE_LINUX_LIBRARIES)
string(APPEND LIBC_LICENSE_FILES " - musl-embedded: third-party-licenses/musl-embedded-COPYRIGHT.txt\n")
if(ENABLE_LINUX_LIBRARIES)
Expand Down Expand Up @@ -867,9 +870,14 @@ list(APPEND third_party_license_files

if(LLVM_TOOLCHAIN_C_LIBRARY MATCHES "^picolibc")
list(APPEND third_party_license_files
${${LLVM_TOOLCHAIN_C_LIBRARY}_SOURCE_DIR}/COPYING.NEWLIB COPYING.NEWLIB
${${LLVM_TOOLCHAIN_C_LIBRARY}_SOURCE_DIR}/COPYING.picolibc COPYING.picolibc
${${LLVM_TOOLCHAIN_C_LIBRARY}_SOURCE_DIR}/COPYING.picolibc COPYING.picolibc
)
# COPYING.NEWLIB has been removed in picolibc 1.8.11 and later.
if(LLVM_TOOLCHAIN_C_LIBRARY STREQUAL "picolibc")
list(APPEND third_party_license_files
${${LLVM_TOOLCHAIN_C_LIBRARY}_SOURCE_DIR}/COPYING.NEWLIB COPYING.NEWLIB
)
endif()
elseif(LLVM_TOOLCHAIN_C_LIBRARY STREQUAL musl-embedded)
list(APPEND third_party_license_files
${musl-embedded_SOURCE_DIR}/COPYRIGHT musl-embedded-COPYRIGHT.txt
Expand Down
4 changes: 2 additions & 2 deletions qualcomm-software/embedded-multilib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ set(llvmproject_src_dir ${TOOLCHAIN_SOURCE_DIR}/..)
set(MULTILIB_JSON "" CACHE STRING "JSON file to load library definitions from.")
set(ENABLE_VARIANTS "all" CACHE STRING "Semicolon separated list of variants to build, or \"all\". Must match entries in the json.")
set(C_LIBRARY "picolibc" CACHE STRING "Which C library to use.")
set_property(CACHE C_LIBRARY PROPERTY STRINGS picolibc musl-embedded)
set_property(CACHE C_LIBRARY PROPERTY STRINGS picolibc picolibc-v1812 musl-embedded)

# multilib.json and the per-variant JSON files only know about one
# "picolibc" entry, shared by every fetched picolibc version (e.g.
# picolibc-main), not a separate entry per version. So map C_LIBRARY to
# picolibc-v1812), not a separate entry per version. So map C_LIBRARY to
# its base library name before looking anything up there.
if(C_LIBRARY MATCHES "^picolibc")
set(json_library_key picolibc)
Expand Down
2 changes: 1 addition & 1 deletion qualcomm-software/embedded-runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set(llvmproject_src_dir ${TOOLCHAIN_SOURCE_DIR}/..)
# CMake arguments are loaded from the JSON file depending on which C
# library is used, so this must be set before the JSON is processed.
set(C_LIBRARY "picolibc" CACHE STRING "Which C library to use.")
set_property(CACHE C_LIBRARY PROPERTY STRINGS picolibc musl-embedded)
set_property(CACHE C_LIBRARY PROPERTY STRINGS picolibc picolibc-v1812 musl-embedded)

set(VARIANT_JSON "" CACHE STRING "JSON file to load args from.")
if(VARIANT_JSON)
Expand Down
7 changes: 2 additions & 5 deletions qualcomm-software/embedded-runtimes/meson-cross-build.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ cpp_ld = 'eld'
ar = '@LLVM_BINARY_DIR@/bin/llvm-ar@CMAKE_EXECUTABLE_SUFFIX@'
strip = '@LLVM_BINARY_DIR@/bin/llvm-strip@CMAKE_EXECUTABLE_SUFFIX@'
# only needed to run tests
# setting stdin to /dev/null prevents qemu from fiddling with the echo bit of
# the parent terminal
exe_wrapper = [
'sh',
'-c',
'test -z "$PICOLIBC_TEST" || @Python3_EXECUTABLE@ @picolibc_test_executor_bin@ "$@" < /dev/null',
'env',
'@Python3_EXECUTABLE@',
'@picolibc_test_executor_bin@',
@meson_test_executor_params@]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
from run_qemu import run_qemu
import argparse
import pathlib
import subprocess
import sys


def run(args):
def run(args, extra_args):
# Some picolibc tests expect argv[0] to be literally "program-name", not
# the actual program name.
argv = ["program-name"] + args.arguments
argv = ["program-name"] + extra_args
if args.args:
# In picolibc v1.8.11 and later, arguments from the picolibc tests
# will come as a string rather than a list, so append to the first
# element and let the semihosting library handle the splitting.
argv[0] += " " + args.args
if args.qemu_command:
return run_qemu(
args.qemu_command,
Expand All @@ -30,6 +36,11 @@ def run(args):
pathlib.Path.cwd(),
args.verbose,
args.trace,
# Setting stdin to /dev/null prevents qemu from fiddling with
# the echo bit of the parent terminal when meson runs multiple
# tests in parallel. stdin is only tested by picolibc when
# test-stdin=true, which is not the default.
stdin=subprocess.DEVNULL,
)


Expand Down Expand Up @@ -62,18 +73,21 @@ def main():
help="Print verbose output. This may affect test result, as the output "
"will be added to the output of the test.",
)
parser.add_argument("image", help="image file to execute")
parser.add_argument(
"arguments",
nargs=argparse.REMAINDER,
default=[],
help="optional arguments for the image",
"--args",
help="String containing optional arguments for the image",
)
args = parser.parse_args()
parser.add_argument("image", help="image file to execute")
# FIXME: We need to support picolibc versions both with and without
# https://github.com/picolibc/picolibc/commit/295b45098fb189185c973376b53d48b86b65e4ae.
# Once all supported picolibc versions have this commit (picolibc v1.8.11
# or later), `extra_args` should be removed and this can go back to just
# `parse_args()`.
args, extra_args = parser.parse_known_args()
# --qemu-cpu is encoded with colons instead of commas to survive CMake list
# separator substitution (LIST_SEPARATOR ,). Decode it back here.
args.qemu_cpu = args.qemu_cpu.replace(":", ",") if args.qemu_cpu else None
ret_code = run(args)
ret_code = run(args, extra_args)
sys.exit(ret_code)


Expand Down
2 changes: 2 additions & 0 deletions qualcomm-software/embedded-runtimes/test-support/run_qemu.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def run_qemu(
working_directory,
verbose,
trace,
stdin=None,
):
"""Execute the program using QEMU and return the subprocess return code."""
qemu_params = ["-M", qemu_machine]
Expand Down Expand Up @@ -73,6 +74,7 @@ def run_qemu(

result = subprocess.run(
command,
stdin=stdin,
stdout=subprocess.PIPE,
stderr=sys.stderr,
timeout=timeout,
Expand Down
36 changes: 35 additions & 1 deletion qualcomm-software/embedded-runtimes/test-support/xfails.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ def check_r52_warning():
p = subprocess.run(test_args, capture_output=True, check=False)
return p.returncode != 0

# FIXME: Eventualy it might make more sense to add a `libc` member into
# `XFail` for more direct use depending on how many libc-specific xfails
# are needed. But, while supporting multiple picolibc versions is new,
# using the existing conditionals seems an unobtrusive and flexible way
# forward.
# Test whether picolibc is cpullvm's v1.8.12 version.
def check_picolibc_is_v1812():
return args.libc == 'picolibc-v1812'

# Test whether picolibc is cpullvm's "primary" version (currently between
# v1.8.10 and v1.8.11).
def check_picolibc_is_primary():
return args.libc == 'picolibc'

xfails = [
XFail(
name="no frwpi",
Expand Down Expand Up @@ -175,6 +189,24 @@ def check_r52_warning():
],
description="Disable the tests for now while the issue is being fixed upstream (https://github.com/picolibc/picolibc/pull/1072).",
),
XFail(
name="picolibc v1.8.12 hello-raw",
testnames=[
"test-hello-raw.test",
"test-hello-raw-no-flash.test",
],
result=NewResult.EXCLUDE,
conditional=check_picolibc_is_v1812,
project="picolibc",
variants=[
"aarch64a_tlsie",
"aarch64a_soft_nofp_tlsie",
],
description="picolibc's `*-raw-*` tests rely on serial port usage "
"to exit correctly which our existing wrappers are not "
"setup to handle. Exclude them for now as we aren't losing "
"any significant test coverage by doing so.",
),
XFail(
name="Insufficient RAM",
testnames=[
Expand Down Expand Up @@ -290,8 +322,10 @@ def check_r52_warning():
"std/language.support/support.start.term/quick_exit.pass.cpp",
],
result=NewResult.XFAILED,
conditional=check_picolibc_is_primary,
project="libcxx",
description="at_quick_exit symbol is not found in the picolibc semihosting runtime.",
description="quick_exit, at_quick_exit, and __cxa_at_quick_exit were first added "
"in picolibc v1.8.12. Older versions fail with undefined symbols.",
),
XFail(
name="uchar-cuchar-xpass-picolibc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
From a59afdaf3697da7a1cfc62e0f957be780d6ae11a Mon Sep 17 00:00:00 2001
From: Simi Pallipurath <simi.pallipurath@arm.com>
Date: Thu, 14 Nov 2024 10:07:08 +0000
Subject: Enable libcxx builds

Modifications to build config and linker script required to enable
libc++ builds.
---
meson.build | 12 ++++++++++++
picolibc.ld.in | 3 +++
2 files changed, 15 insertions(+)

diff --git a/meson.build b/meson.build
index f33d011b2..2c653de02 100644
--- a/meson.build
+++ b/meson.build
@@ -1340,6 +1340,18 @@ NEWLIB_MAJOR_VERSION=4
NEWLIB_MINOR_VERSION=3
NEWLIB_PATCHLEVEL_VERSION=0

+conf_data.set('_GNU_SOURCE', '',
+ description: '''Enable GNU functions like strtof_l.
+It's necessary to set this globally because inline functions in
+libc++ headers call the GNU functions.'''
+)
+
+conf_data.set('_PICOLIBC_CTYPE_SMALL', '0',
+ description: '''Disable picolibc's small ctype implementation.
+libc++ expects newlib-style ctype tables, and also expects support for locales
+and extended character sets, so picolibc's small ctype is not compatible with it'''
+)
+
conf_data.set('__HAVE_CC_INHIBIT_LOOP_TO_LIBCALL',
cc.has_argument('-fno-tree-loop-distribute-patterns'),
description: 'Compiler flag to prevent detecting memcpy/memset patterns')
diff --git a/picolibc.ld.in b/picolibc.ld.in
index 0bcfe4ca8..c3055c49e 100644
--- a/picolibc.ld.in
+++ b/picolibc.ld.in
@@ -69,6 +69,9 @@ SECTIONS
*(.literal.startup .text.startup .literal.startup.* .text.startup.*)
*(SORT(.text.sorted.*))
*(.literal .text .literal.* .text.* .opd .opd.* .branch_lt .branch_lt.* @EXTRA_TEXT_SECTIONS@)
+ PROVIDE (__start___lcxx_override = .);
+ *(__lcxx_override)
+ PROVIDE (__stop___lcxx_override = .);
*(.gnu.linkonce.t.*)
KEEP (*(.fini .fini.*))
@PREFIX@__text_end = .;
--
2.43.0

Loading
Loading