PLC-lang / rusty

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

Duplicate symbol error when aliasing to same hardware address across multiple files #1307

Open mhasel opened 2 months ago

mhasel commented 2 months ago

With #1301 we submitted a fix to prevent the pre-processor to generate multiple global variables mapping the same address variable, e.g.:

VAR_GLOBAL
    foo AT %IX1.2.3.4 : BOOL;
    bar AT %IX1.2.3.4 : BOOL;
END_VAR

While the above example now compiles without error, the following example will still fail to compile, reporting ambiguous global variables:

file1.st:

VAR_GLOBAL
foo AT %IX1.2.3.4 : BOOL;
END_VAR

file2.st

VAR_GLOBAL
bar AT %IX1.2.3.4 : BOOL;
END_VAR

This is due to the pre-processor only checking for already existing internally mangled globals on a unit-by-unit basis.