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

sys/tiny_strerror: fix compilation with picolibc on Ubuntu #21162

Conversation

maribu
Copy link
Member

@maribu maribu commented Jan 24, 2025

Contribution description

The picolibc shipped in Ubuntu does not provided non-POSIX errnos by default. If the errno codes are not provided, we can also not provide corresponding strings.

This guards the effected strings corresponding to non-POSIX errnos behind #ifdef, so that they are only provided when the corresponding errno is.

Testing procedure

$ FEATURES_REQUIRED=picolibc make BOARD=nucleo-f767zi -C tests/periph/selftest_shield
on Ubuntu with master gives:
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:146:6: error: 'EHOSTDOWN' undeclared here (not in a function); did you mean 'ENETDOWN'?
  146 |     [EHOSTDOWN]         = _ehostdown,
      |      ^~~~~~~~~
      |      ENETDOWN
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:146:6: error: array index in initializer not of integer type
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:146:6: note: (near initialization for 'lookup')
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:176:27: error: initialized field overwritten [-Werror=override-init]
  176 |     [ENOSPC]            = _enospc,
      |                           ^~~~~~~
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:176:27: note: (near initialization for 'lookup[28]')
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:191:6: error: 'EPFNOSUPPORT' undeclared here (not in a function); did you mean 'EAFNOSUPPORT'?
  191 |     [EPFNOSUPPORT]      = _epfnosupport,
      |      ^~~~~~~~~~~~
      |      EAFNOSUPPORT
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:191:6: error: array index in initializer not of integer type
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:191:6: note: (near initialization for 'lookup')
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:191:27: error: initialized field overwritten [-Werror=override-init]
  191 |     [EPFNOSUPPORT]      = _epfnosupport,
      |                           ^~~~~~~~~~~~~
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:191:27: note: (near initialization for 'lookup[2]')
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:203:6: error: 'ETOOMANYREFS' undeclared here (not in a function)
  203 |     [ETOOMANYREFS]      = _etoomanyrefs,
      |      ^~~~~~~~~~~~
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:203:6: error: array index in initializer not of integer type
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:203:6: note: (near initialization for 'lookup')
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:203:27: error: initialized field overwritten [-Werror=override-init]
  203 |     [ETOOMANYREFS]      = _etoomanyrefs,
      |                           ^~~~~~~~~~~~~
/home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror/tiny_strerror.c:203:27: note: (near initialization for 'lookup[63]')

with this PR:

...
"make" -C /home/[email protected]/Repos/software/RIOT/master/sys/tiny_strerror
"make" -C /home/[email protected]/Repos/software/RIOT/master/sys/tsrb
   text	  data	   bss	   dec	   hex	filename
  13396	    44	  2400	 15840	  3de0	/home/[email protected]/Repos/software/RIOT/master/tests/periph/selftest_shield/bin/nucleo-f767zi/tests_selftest_shield.elf
make: Leaving directory '/home/[email protected]/Repos/software/RIOT/master/tests/periph/selftest_shield'

Issues/PRs references

None

The picolibc shipped in Ubuntu does not provided non-POSIX errnos
by default. If the errno codes are not provided, we can also not
provide corresponding strings.

This guards the effected strings corresponding to non-POSIX errnos
behind `#ifdef`, so that they are only provided when the corresponding
errno is.
@maribu maribu added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 24, 2025
@maribu maribu requested a review from benpicco January 24, 2025 11:10
@github-actions github-actions bot added the Area: sys Area: System label Jan 24, 2025
@maribu
Copy link
Member Author

maribu commented Jan 24, 2025

@MrKevinWeiss Do you want this to be backported?

Compilation works fine with BUILD_IN_DOCKER=1; it only affects an older version of picolibc shipped in Ubuntu.

It certainly is a rather un-scary and trivial fix, though.

@riot-ci
Copy link

riot-ci commented Jan 24, 2025

Murdock results

✔️ PASSED

28caf32 sys/tiny_strerror: fix compilation with picolibc on Ubuntu

Success Failures Total Runtime
10271 0 10271 10m:47s

Artifacts

@benpicco benpicco enabled auto-merge January 24, 2025 13:09
@benpicco benpicco added this pull request to the merge queue Jan 24, 2025
Merged via the queue into RIOT-OS:master with commit 95c0a62 Jan 24, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants