Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picolibc: tests with meson #254

Merged

Conversation

domin144
Copy link
Contributor

Switch from manually building picolibc tests to bilding and running them
as part of picolibc build. This enables tests, which were not included
in the manual build.

Several fixes were necessary:

  1. Add '-nostdlib' to picolibc c_args
    This prevents errors like:
    ld.lld: error: unable to find library -lc
    in checks for compiler flags support in picolibs build scripts.
    Example of failing check:
    has_link_defsym = meson.get_cross_property('has_link_defsym', cc.has_link_argument('-Wl,--defsym=' + global_prefix + '_start=0'))

  2. Make picolibc use compiler_rt in place of libgcc.

  3. Change machines used with qemu and adjust memory layouts.
    Some of picolibc tests need more memory, than previous machines
    provided. Example error:
    ld.lld: error: section '.text' will not fit in region 'flash': overflowed by 34504 bytes

  4. Postpone building picolibc tests to the test step. compiler_rt
    requires picolibc to be installed. picolibc tests require compiler_rt.
    The delayed tests enable picolibc to be installed before compiler_rt is built.

Copy link
Contributor

@mplatings mplatings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, thanks

CMakeLists.txt Outdated Show resolved Hide resolved
test-support/run-picolibc-test.py Outdated Show resolved Hide resolved
cmake/to_meson_list.cmake Outdated Show resolved Hide resolved
@domin144 domin144 force-pushed the picolib_run_tests_with_meson_redo branch from aa20239 to 4b25128 Compare June 16, 2023 11:48
@domin144
Copy link
Contributor Author

I applied corrections for the comments.
I also removed the linker scripts and replaced with default ones, which now have values matching our test platforms.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
test-support/lit-exec-qemu.py Outdated Show resolved Hide resolved
test-support/run-picolibc-test.py Outdated Show resolved Hide resolved
test-support/run-picolibc-test.py Outdated Show resolved Hide resolved
test-support/run-picolibc-test.py Outdated Show resolved Hide resolved
test-support/run-picolibc-test.py Outdated Show resolved Hide resolved
@domin144 domin144 force-pushed the picolib_run_tests_with_meson_redo branch from 4b25128 to d527131 Compare June 21, 2023 13:45
@domin144
Copy link
Contributor Author

I addressed some of the issues in a separate PR #256 to make changes reviewable.
I will rebase this PR, when those changes are merged.

@domin144 domin144 force-pushed the picolib_run_tests_with_meson_redo branch from d527131 to c9a33a0 Compare June 26, 2023 11:58
Switch from manually building picolibc tests to bilding and running them
as part of picolibc build. This enables tests, which were not included
in the manual build.

Several fixes were necessary:

1. Add '-nostdlib' to picolibc c_args
This prevents errors like:
  ld.lld: error: unable to find library -lc
in checks for compiler flags support in picolibs build scripts.
Example of failing check:
  has_link_defsym = meson.get_cross_property('has_link_defsym', cc.has_link_argument('-Wl,--defsym=' + global_prefix + '_start=0'))

2. Make picolibc use compiler_rt in place of libgcc.

3. Change machines used with qemu and adjust memory layouts.
Some of picolibc tests need more memory, than previous machines
provided. Example error:
  ld.lld: error: section '.text' will not fit in region 'flash': overflowed by 34504 bytes

4. Postpone building picolibc tests to the test step. compiler_rt
requires picolibc to be installed. picolibc tests require compiler_rt.
The delayed tests enable picolibc to be installed before compiler_rt is built.
Copy link
Contributor

@mplatings mplatings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there!

# https://mesonbuild.com/Unit-tests.html#skipped-tests-and-hard-errors
EXIT_CODE_SKIP = 77

disabled_tests = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This information doesn't belong in this file.

@@ -5,15 +5,53 @@
# This script is a bridge between lit-based tests of LLVM C++ runtime libraries
# (libc++abi, libunwind, libc++) and QEMU. It must handle the same command-line
# arguments as llvm-project/libcxx/utils/run.py.
# This is also a wrapper script to run picolibc tests with QEMU.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes against the philosophy of "Make each program do one thing well."

CMakeLists.txt Outdated
# the full target, which would include tests. Picolibc tests, are enabled
# only in tests step, otherwise, they would be built before install.
add_custom_target(compiler_rt_${variant}-available)
ExternalProject_Add_StepDependencies(picolibc_${variant} test compiler_rt_${variant}-available)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could a standard step be used instead? e.g. compiler_rt_${variant}-install

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more readable, but the issue is, the target has to exist at the point where ExternalProject_Add_StepDependencies is called and compiler_rt_${variant}-install is created later, by ExternalProject call for compiler_rt. I added this dummy compiler_rt_${variant}-available to resolve the mutual dependency between picolibc and compiler-rt.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the target has to exist at the point where ExternalProject_Add_StepDependencies is called

Are you sure? Usually in CMake targets don't have to exist at the point the dependency is declared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. CMake happily accepted the -install target. I will fix this in next iteration.

@domin144 domin144 force-pushed the picolib_run_tests_with_meson_redo branch from c9a33a0 to 158598c Compare July 7, 2023 11:43
@domin144
Copy link
Contributor Author

domin144 commented Jul 7, 2023

I uploaded a new patch. I won't be able to address new comments till Tuesday.

Copy link
Contributor

@mplatings mplatings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@domin144 domin144 merged commit 8076b6e into ARM-software:main Jul 11, 2023
1 check passed
@domin144 domin144 deleted the picolib_run_tests_with_meson_redo branch July 11, 2023 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants