Commit 48580fd
Ralph Küpper
fix(codegen): record a stable source_filename on emitted modules
`cargo-test` has been red on main since #8062/#8068/#8071 landed, on four
perry-codegen tests that assert the textual and native construction paths
emit byte-identical objects. The code they generate already converged; the
objects differed only in the name LLVM records for the module.
Nothing set `source_filename`, so LLVM fell back to whatever path reached
the assembler. The textual pipeline writes each module to a per-call temp
file, so its recorded name carried a random nonce (`perry_llvm_<nonce>.ll`);
native construction recorded its in-memory module id (`perry_native_module`)
instead. ELF stores that name as an `STT_FILE` symbol, so the two paths
could never agree and neither was reproducible run to run. Mach-O records no
such symbol, which is why every one of these tests passes on a macOS host
and fails only on the Linux runner.
Emit an explicit `source_filename` from all three module-header sites
(`to_ir`, `skeleton_ir`, and the per-codegen-unit prologue) so the recorded
name is the same constant on both paths and independent of the temp path.
The `inprocess` fold-order test named its two arms apart itself, which put
the same difference in a `.file` directive; both arms now emit under one
name, leaving the generated code as the only thing the assertion compares.1 parent 86967ca commit 48580fd
3 files changed
Lines changed: 112 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
519 | 519 | | |
520 | 520 | | |
521 | 521 | | |
522 | | - | |
523 | | - | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
524 | 530 | | |
525 | 531 | | |
526 | 532 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
352 | 364 | | |
353 | 365 | | |
354 | 366 | | |
| |||
680 | 692 | | |
681 | 693 | | |
682 | 694 | | |
| 695 | + | |
683 | 696 | | |
684 | 697 | | |
685 | 698 | | |
| |||
720 | 733 | | |
721 | 734 | | |
722 | 735 | | |
| 736 | + | |
723 | 737 | | |
724 | 738 | | |
725 | 739 | | |
| |||
1030 | 1044 | | |
1031 | 1045 | | |
1032 | 1046 | | |
| 1047 | + | |
1033 | 1048 | | |
1034 | 1049 | | |
1035 | 1050 | | |
| |||
1470 | 1485 | | |
1471 | 1486 | | |
1472 | 1487 | | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
1473 | 1537 | | |
1474 | 1538 | | |
1475 | 1539 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
598 | 605 | | |
599 | 606 | | |
600 | 607 | | |
| |||
785 | 792 | | |
786 | 793 | | |
787 | 794 | | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
788 | 827 | | |
789 | 828 | | |
790 | 829 | | |
| |||
0 commit comments