Issue Details (XML | Word | Printable)

Key: PCC-480
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Anders Magnusson
Reporter: rl
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
pcc

code generated without -O looks incompatible with musl variadic arguments (?)

Created: 28/Aug/14 03:24 PM   Updated: 14/Sep/14 06:52 PM
Component/s: C frontend, i386 target
Affects Version/s: None
Fix Version/s: None

Environment: pcc 20140824, musl 1.1.4, i486-pc-linux-gnu


 Description  « Hide
musl compilation with pcc without supplying any optimization
arguments produces a library where variadic argument handling
looks broken
(*printf() functions pick unrelated data instead of the extra arguments).

This is observed both with static and dynamic linking.

The same library compiled with -Os behaves healthy.

(lacking time for a deeper exploration, reporting as-is)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Anders Magnusson added a comment - 28/Aug/14 10:34 PM
I need examples here, otherwise it will be too much work to try to find the bugs. I could not find any bugs with a simple test.

rl added a comment - 29/Aug/14 11:40 AM
I can not reproduce the issue by recompilation of the concerned musl stdio routines, despite the problem consequently manifesting itself when the whole library is rebuild.
The problem is thus most probably at a different place in the library.

The failing test:

a.c:
--------
#include <stdio.h>

main(int argc, char **argv){
  printf("as much is working\n");
  return printf("%d\n", 1);
}
-------
pcc -o a a.c (optimization flags do not affect here)
./a; echo $?
as much is working
-134236096
11

pcc -static -o a a.c
./a; echo $?
as much is working
-9788
6

Anders Magnusson added a comment - 29/Aug/14 11:15 PM
Note that any O flag (except -O0) turns on optimization. There is only one opt-level.

Anders Magnusson added a comment - 13/Sep/14 09:46 AM
An i386 bug found and fixed. Please try again.

rl added a comment - 14/Sep/14 05:33 PM
This seems to correct the issue.
I can properly run a test case with musl-1.1.4 on i386, compiled with today's pcc without optimization,
while a library built with the yesterday's version of pcc failed as before.
Thanks!

Anders Magnusson added a comment - 14/Sep/14 06:52 PM
Fixed as a side-effect of PCC-484.