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

CI: Build check with various optimization levels #546

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ChinYikMing
Copy link
Collaborator

The submodules are built locally, which may lead to build failures. Specifically, the dtc submodule fails to build when using GCC versions 11.4.0 or 12.3.0 with optimization levels set to -O0 or with debug flag -g. This is a critical issue, as it can disable the debug mode. To address this, optimization levels and debug level build are introduced to stabilize the pull request changes.

The compiled error:
/usr/bin/ld: /tmp/cc2eaHdM.ltrans0.ltrans.o: in function fdt_del_node': :(.text+0x279f0): undefined reference to fdt_node_end_offset_' collect2: error: ld returned 1 exit status

Note: I have only used gcc 11.4.0 and gcc 12.3.0 to test this out. Github runners should test other compilers.

After bisecting, the original cause was found after #534.

@ChinYikMing
Copy link
Collaborator Author

ChinYikMing commented Jan 25, 2025

See action for more information.

Clang has no problem with various optimization build. Interesting.

@RinHizakura
Copy link
Collaborator

RinHizakura commented Jan 25, 2025

This is not the right way to fix it. The issue could happen because I only compile the object that I think we need, but maybe more objects are required for -g + -O0. However, this can't explain the different results on Clang and GCC that you mentioned. I also have no idea here.

Can you check if you can also fix this with the following change?

--- a/mk/system.mk
+++ b/mk/system.mk
@@ -28,7 +28,7 @@ DEV_OBJS := $(patsubst $(DEV_SRC)/%.c, $(DEV_OUT)/%.o, $(wildcard $(DEV_SRC)/*.c
 deps := $(DEV_OBJS:%.o=%.o.d)

 OBJS_EXT += system.o
-OBJS_EXT += dtc/libfdt/fdt.o dtc/libfdt/fdt_ro.o dtc/libfdt/fdt_rw.o
+OBJS_EXT += dtc/libfdt/fdt.o dtc/libfdt/fdt_ro.o dtc/libfdt/fdt_rw.o dtc/libfdt/fdt_wip.o

@RinHizakura
Copy link
Collaborator

RinHizakura commented Jan 25, 2025

Oh sorry, not aware that you are just trying to robust the CI/CD here instead of fixing anything. We can accept the test first and fix it in another PR.

CC: ${{ steps.install_cc.outputs.cc }}
run: |
make distclean
make OPT_LEVEL=-Ofast ENABLE_SYSTEM=1 -j$(nproc)
Copy link
Collaborator

@RinHizakura RinHizakura Jan 25, 2025

Choose a reason for hiding this comment

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

Not sure if we need to take care of -Os or even just retain the presentative -O level only, otherwise the possible options may be too many. Will let @jserv decide this.

Copy link
Collaborator Author

@ChinYikMing ChinYikMing Jan 25, 2025

Choose a reason for hiding this comment

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

One more -Oz can be the candidate. It is related to size just like -Os. Thus, not embracing them at first.

@ChinYikMing
Copy link
Collaborator Author

Oh sorry, not aware that you are just trying to robust the CI/CD here instead of fixing anything. We can accept the test first and fix it in another PR.

Agree. Thanks! Since with default -O2 build, the problem does not exist. I revealed this problem when trying to do some debugging.

@ChinYikMing
Copy link
Collaborator Author

This is not the right way to fix it. The issue could happen because I only compile the object that I think we need, but maybe more objects are required for -g + -O0. However, this can't explain the different results on Clang and GCC that you mentioned. I also have no idea here.

Can you check if you can also fix this with the following change?

--- a/mk/system.mk
+++ b/mk/system.mk
@@ -28,7 +28,7 @@ DEV_OBJS := $(patsubst $(DEV_SRC)/%.c, $(DEV_OUT)/%.o, $(wildcard $(DEV_SRC)/*.c
 deps := $(DEV_OBJS:%.o=%.o.d)

 OBJS_EXT += system.o
-OBJS_EXT += dtc/libfdt/fdt.o dtc/libfdt/fdt_ro.o dtc/libfdt/fdt_rw.o
+OBJS_EXT += dtc/libfdt/fdt.o dtc/libfdt/fdt_ro.o dtc/libfdt/fdt_rw.o dtc/libfdt/fdt_wip.o

Tested it out, fixed it! Another commit will be push later.

@ChinYikMing
Copy link
Collaborator Author

@RinHizakura One more thing, I noticed the dtc submodule has integrated the dtc compiler, shall we use it? So that, the new user does not need to install the dtc on their own.

@ChinYikMing
Copy link
Collaborator Author

ChinYikMing commented Jan 25, 2025

The action that passed the various optimization level build after apply commit 139af81: link.

@otteryc
Copy link

otteryc commented Jan 26, 2025

Link-Time Optimization (LTO) may be the culprit when building with -O0 flag. GCC worked fine after adding the -fno-lto flag.

@ChinYikMing
Copy link
Collaborator Author

Link-Time Optimization (LTO) may be the culprit when building with -O0 flag. GCC worked fine after adding the -fno-lto flag.

Without modifying the lto configuration, adding this object dtc/libfdt/fdt_wip.o solves it.

@RinHizakura
Copy link
Collaborator

One more thing, I noticed the dtc submodule has integrated the dtc compiler, shall we use it? So that, the new user does not need to install the dtc on their own.

I think we don't need to introduce such complications because building dtc may require other dependencies.

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Rebase the latest master branch to resolve Arm64 host breakage on CI.

Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Benchmarks

Benchmark suite Current: 1a2bcc9 Previous: 64ea138 Ratio
Dhrystone 1313 Average DMIPS over 10 runs 1324 Average DMIPS over 10 runs 1.01
Coremark 962.001 Average iterations/sec over 10 runs 969.943 Average iterations/sec over 10 runs 1.01

This comment was automatically generated by workflow using github-action-benchmark.

The submodules are built locally, which may lead to build failures.
Specifically, the dtc submodule fails to build when using GCC versions
11.4.0 or 12.3.0 with optimization levels set to -O0 or with debug flag
-g. This is a critical issue, as it can disable the debug mode. To
address this, optimization levels and debug level build are introduced
to stabilize the pull request changes.

The compiled error:
/usr/bin/ld: /tmp/cc2eaHdM.ltrans0.ltrans.o: in function fdt_del_node':
<artificial>:(.text+0x279f0): undefined reference to fdt_node_end_offset_'
collect2: error: ld returned 1 exit status

Note: I have only used gcc 11.4.0 and gcc 12.3.0 to test this out.
Github runners should test other compilers.

After bisecting, the original cause was found after sysprog21#534.
The build error:
/usr/bin/ld: /tmp/cc2eaHdM.ltrans0.ltrans.o: in function fdt_del_node':
<artificial>:(.text+0x279f0): undefined reference to fdt_node_end_offset_'
collect2: error: ld returned 1 exit status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants