blech-lang / blech

Blech is a language for developing reactive, real-time critical embedded software.
Apache License 2.0
64 stars 5 forks source link

Generated test application (blechc -app) includes the blech program as .c file #12

Open schorg opened 1 year ago

schorg commented 1 year ago

The Blech compiler automatically generates a test program - blech.c by default - with the following command line

blechc --app --trace control.blc

Compiling all generated C-files generates duplicate symbol warnings.

cd blech
clang -Iinclude *.c
duplicate symbol '_blc_blech_01control01_init' in:
    /var/folders/l9/p0sgmsvj16v16tgzlplc3flm0000gn/T/blech-4471ee.o
    /var/folders/l9/p0sgmsvj16v16tgzlplc3flm0000gn/T/control-74f76a.o
... and so on

Reason: The EntryPoint file control.c is included as a control.c instead of control.h into blech.c.

I am on it.

FriedrichGretz commented 1 year ago

It is not a bug, it is a feature which, however, confuses even those who introduced it years ago ;-)

schorg commented 1 year ago

Can't remember the reason. Can you elaborate on this

FriedrichGretz commented 1 year ago

Before pushing to master, did you check all the code gen tests? With your commit all of them should be broken, if I remember correctly

FriedrichGretz commented 1 year ago

The test program and the blech.c are tightly coupled so instead of including the header and compiling to C files, we directly include the code and you only need to compile the test program. Additionally compiling the blech.c is what raised the warnings.

schorg commented 1 year ago

Created a branch for this. The issue creates problems when compiling the C code to WebAssembly. I will look into the code generation tests, before I do a pull request

FriedrichGretz commented 1 year ago

Ah sorry, did not see the new branch when I clicked on the commit