Non-conforming `printf` prototypes in the GCC/Rust testsuite
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
Just for fun, I tried enabling GCC/Rust in my GCC/nvptx target testing (see https://gcc.gnu.org/wiki/nvptx).
As you'd hope, it generally works.
One issue, however, is that in our hacked-up printf test cases, we use:
extern "C" {
fn printf(s: *const i8, ...);
}
..., which GCC/nvptx turns into:
.extern .func printf (.param.u64 %in_ar0, .param.u64 %in_ar1);
In contrast, the libc one is declared/defined as:
.visible .func (.param .u32 %value_out) printf (.param .u64 %in_ar0, .param .u64 %in_ar1);
(That is, with the expected int return type; don't ask me why unsigned .u32 instead of signed .s32, but apparently that's OK.)
Therefore, all those execution tests FAIL:
error : Prototype doesn't match for 'printf' [...]
nvptx-run: cuLinkAddData failed: unknown error (CUDA_ERROR_UNKNOWN, 999)
Should I fix all those up like (a):
extern "C" {
- fn printf(s: *const i8, ...);
+ fn printf(s: *const i8, ...) -> i32;
}
..., which should be correst most of all times, or (b):
+pub type c_int = i32;
extern "C" {
- fn printf(s: *const i8, ...);
+ fn printf(s: *const i8, ...) -> c_int;
}
..., to make that more obvious, or (c) something else?
(See https://doc.rust-lang.org/stable/std/ffi/type.c_int.html.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the GCC/Rust testsuite execution cases that declare the variadic printf function and compare them with the libc declaration used by GCC/nvptx. Confirm the appropriate return type and update the affected declarations so the nvptx prototypes match, then rerun the execution tests and verify that the printf prototype errors are gone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100