Open eli-schwartz opened 8 months ago
Presumably this is due to, -Werror=lto-type-mismatch
, but it's unclear how to address it (at least, unclear to me). p9main
here must (unfortunately?) emulate the behavior of main
in ignoring its arguments if they are not specified; hence the void p9main(void)
formulation. Short of doing a major revision to the source code, this is something that we'll have to figure out how to convince the compiler (or, rather, linker) of being explicitly acceptable.
p9main
here must (unfortunately?) emulate the behavior ofmain
in ignoring its arguments if they are not specified; hence thevoid p9main(void)
formulation.
Do you mean accepting arguments and then just silently never using their values for any purposes?
Not precisely.
In standard C, main
is special in that it can be declared several different ways. Notably, int main(int argc, char *argv[])
and int main(void)
are both legal; to my knowledge, no other C function is special-cased in the same way (variadic functions are different). The linker must obviously support this as a special case when warning about type mismatches.
The issue with Plan 9 C is that main
was declared to return void
(that is, have no return value); instead, main
is expected to call exits()
with a pointer to some status string (or nil
, usually just written as 0
). For plan9port, p9main
is basically a wrapper function that emulates the difference between main
in standard and Plan 9 C. However, plan 9 C continued to support the void main(void)
vs void main(int argc, char *argv[])
for the benefit of programs that take or do not take command line arguments. But the special case for "real" main
doesn't exist for p9main
, hence this error.
One wonders if there's a magic flag that would tell the linker, "ignore type mismatches for this particular function." If so, that's the simplest fix.
I tried to build with these *FLAGS set:
-flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
I got this compiler error:
Downstream report: https://bugs.gentoo.org/858452