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

be/c: use temporary file for emitting c-code #2605

Conversation

michaellilltokiwa
Copy link
Member

@michaellilltokiwa michaellilltokiwa commented Feb 23, 2024

PR due to @maxteufel suggestion from here: #2574 (review)

example output:

/home/not_synced/fuzion (2024-02-23T11-51-27+01-00)$ fz -verbose=1 -c tests/hello/HelloWorld.fz 

warning 1: New clazz created during layout phase: (list u8).as_array.#fun1.call


warning 2: New clazz created during layout phase: (list u8).as_stream.as_stream


warning 3: New clazz created during layout phase: (list u8).as_array.lm.#fun52.call


warning 4: New clazz created during layout phase: ((list u8).as_array.lm.go (array u8)).#fun2.call

 + /tmp/fuzion-3219614508357886221.c
 * clang -Wall -Werror -Wno-trigraphs -Wno-gnu-empty-struct -Wno-unused-variable -Wno-unused-label -Wno-unused-function -Wno-infinite-recursion -Wno-unused-but-set-variable -O3 -lgc -DGC_THREADS -DGC_PTHREADS -DPTW32_STATIC_LIB -DGC_WIN32_PTHREADS -fno-trigraphs -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -std=c11 -o HelloWorld /home/not_synced/fuzion/build/include/shared.c /home/not_synced/fuzion/build/include/posix.c /tmp/fuzion-3219614508357886221.c
Elapsed time for phases: prep 31ms, fe 75ms, createMIR 1ms, me 68ms, ir 645ms, effectsCheck 132ms, be 1234ms
4 warnings.

@michaellilltokiwa michaellilltokiwa added enhancement New feature or request C backend related to the C backend labels Feb 23, 2024
@fridis
Copy link
Member

fridis commented Feb 23, 2024

It is much nicer not dumping temporary files into the current directory.

I think these temp files are not deleted automatically, so this will result in lots of temp files with ending up in /tmp. But when they are automatically deleted, we will need some option for the fz command to keep them for our debugging.

Also, I think it would be better to include the main feature name just to make this a little less confusion, i..e, create /tmp/fuzion-helloworld-3219614508357886221.c.

@michaellilltokiwa
Copy link
Member Author

I think these temp files are not deleted automatically, so this will result in lots of temp files with ending up in /tmp. But when they are automatically deleted, we will need some option for the fz command to keep them for our debugging.

My understanding is that the OS is responsible to delete these files after a while. For example when rebooting.

@maxteufel
Copy link
Collaborator

My understanding is that the OS is responsible to delete these files after a while.

The OS can delete them after a while, but likely we will do ourselves a favor if we remove the files unless an option is set to keep the files. You don't want to try every one of them if you're debugging something.

@michaellilltokiwa
Copy link
Member Author

michaellilltokiwa commented Feb 26, 2024

@maxteufel I added an option -XkeepGeneratedCode as suggested. Also temporary c-file gets deleted when java exists.

Copy link
Collaborator

@maxteufel maxteufel left a comment

Choose a reason for hiding this comment

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

I expected this to simply keep the files in /tmp but this works too.

@@ -145,8 +145,6 @@ int fzE_munmap(void * mapped_address, const int file_size);
* results is unequality of +0 and -0 and equality of NaN unless undefined bits
* differ, etc.
*
* NYI: CLEANUP #2122: Move impleementation to fz.c / fzlib.o or similar!
Copy link
Collaborator

Choose a reason for hiding this comment

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

is that done without precompiling the library?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently yes, see issue #2589

Copy link
Collaborator

Choose a reason for hiding this comment

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

no i mean this comment shouldn't be removed then since the task is not done yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

do not forget to change this in flang.dev, too

src/dev/flang/tools/Fuzion.java Outdated Show resolved Hide resolved
@maxteufel maxteufel merged commit 8c63e79 into tokiwa-software:main Feb 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C backend related to the C backend enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants