Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C] do not generate code without main reactor #1000

Merged
merged 5 commits into from
Mar 9, 2022

Conversation

housengw
Copy link
Contributor

@housengw housengw commented Mar 3, 2022

Do not generate code when there is no main reactor

Fixes #913

@housengw housengw changed the title [C target] do not generate code without main reactor [C] do not generate code without main reactor Mar 3, 2022
@housengw housengw requested a review from Soroosh129 March 4, 2022 07:31
@lhstrh
Copy link
Member

lhstrh commented Mar 7, 2022

How does this PR relate to #913? Not generating code when there is no main reactor means that we cannot generate any pure library code. Is that really what we want?

@housengw
Copy link
Contributor Author

housengw commented Mar 7, 2022

The error outlined in #913 is due to CGenerator not checking if main reactor exist before generating code in doGenerate.

The Cpp target also doesnt generate code when there is no main reactor. It might make sense to standardize code generation behavior across targets.

@cmnrd
Copy link
Collaborator

cmnrd commented Mar 7, 2022

I think we should really generate a library if there is no main reactor. In fact, I think we should create a library for all LF files and only generate a small binary that uses this library if there is a main reactor. Note that for C++ we have a long open issue: #83.

For the short term solution, though, it might be better to just forbid compilation without a main reactor. Without a package system, it does not make much sense to compile LF programs as libraries.

Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good quick fix. Like @cmnrd said, more work would be needed for the generation of library code. I've made suggestions for the removal of checks that I think are unnecessary.

org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
@lhstrh
Copy link
Member

lhstrh commented Mar 8, 2022

Oh, and congrats on filing PR #1000 🥳

Copy link
Member

@lhstrh lhstrh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more suggestion.

org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
org.lflang/src/org/lflang/generator/GeneratorUtils.java Outdated Show resolved Hide resolved
housengw and others added 2 commits March 8, 2022 14:47
@lhstrh lhstrh merged commit 9e5e5a1 into master Mar 9, 2022
@lhstrh lhstrh deleted the c-do-not-generate-without-main branch March 9, 2022 01:08
@lhstrh lhstrh added the bug Something isn't working label Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Files without main don't compile if they have imports
3 participants