PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
181 stars 47 forks source link

Leading comma in section name when running tests under MacOS #1192

Open volsa opened 1 month ago

volsa commented 1 month ago

Describe the bug Currently cargo test will fail with snapshot diffs because a leading comma is appended to the section names. For example the test multiple_files_with_debug_info will fail due to

-define i16 @main() section "fn-main:i16" !dbg !10 {
+define i16 @main() section ",fn-main:i16" !dbg !10 {

-declare !dbg !18 void @mainProg(%mainProg*) section "fn-mainProg:v"
+declare !dbg !18 void @mainProg(%mainProg*) section ",fn-mainProg:v"

-define void @mainProg(%mainProg* %0) section "fn-mainProg:v" !dbg !10 {
+define void @mainProg(%mainProg* %0) section ",fn-mainProg:v" !dbg !10 {

I'm unsure if this is a MacOS thing or ARM in general but I suspect the former.

To Reproduce Under MacOS 14.4.1 switch to the master branch and run cargo t

Expected behavior The snapshots shouldn't change

volsa commented 1 month ago

Hmm, maybe this isn't a bug after all? Inkwell does this intentionally here https://github.com/TheDan64/inkwell/blob/d916c66d2cedb8bc58c187df8403d9fc71eb0ad4/src/values/mod.rs#L219

volsa commented 3 weeks ago

I tried fixing the snapshot tests under MacOS, removing these leading commas for all tests in the codegen/ folder such that the IR is identical to the master branch. While its working (see https://github.com/PLC-lang/rusty/compare/macos-codegen) the correctness and integration tests fail with a sigbus panic. Not sure why, but the section names seem to cause the panic under MacOS. This needs further investigation...

Edit: https://www.diffchecker.com/YMExZsik/