Skip to content

debug build improvements #7591

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

Closed
wants to merge 1 commit into from
Closed

Conversation

gneverov
Copy link

@gneverov gneverov commented Feb 16, 2023

Here is a bunch of changes that I found potentially helpful while debugging issue #7333. If you think they are useful too, I can PR all of part of this. Either way it is not a big deal.

  1. Change debug optimization level to O1 to make code more debuggable.
  2. I use CIRCUITPY_FULLBUILD = 0 as a cheesy way to get faster builds. Doing this introduced some missing dependencies, so I added them to mpconfig mk/h files.
  3. In order for a build to fail sooner on a missing dependency, I added this #if #error pattern to some leaf header files. So if some code uses these headers, but they are not going to be built, it fails a compile-time instead of link-time. If accepted, this pattern should be applied in more places.
  4. I'm not sure how web workflow would make sense without wifi and getenv, so I removed some checks. Now because of (3), web workflow will fail to build without wifi and getenv.

@gneverov
Copy link
Author

This change is going to expose a lot of issues. The current issue in CI is that getenv support is being built even if it is disabled in the config. Let me know if you'd like me to keep pulling on this thread, or if you'd rather just let it be.

@@ -160,7 +160,7 @@ CFLAGS += $(OPTIMIZATION_FLAGS)
CFLAGS += $(CFLAGS_CYW43)
#Debugging/Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -ggdb3 -O3
CFLAGS += -ggdb3 -O1
Copy link
Collaborator

Choose a reason for hiding this comment

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

We would usually use -Og, but you said that didn't work. if -O1 works, let's leave it and add a comment about what was tried and what didn't work.

@@ -5,6 +5,7 @@
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_DRIVE_MODE (1)

#define MICROPY_HW_LED_STATUS (&pin_CYW0)
#define MICROPY_PY_COLLECTIONS_DEQUE (1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be promoted up to mpconfigport.h. It should be on for all but the smallest builds.

Copy link
Author

Choose a reason for hiding this comment

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

Deque is used by wifi, and not all rp2 boards have wifi, so that's why I put it at the board level.

Copy link
Collaborator

Choose a reason for hiding this comment

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

See #6474; we generally want deque on; only turning it off on the smallest builds.

Comment on lines -63 to -69
#if CIRCUITPY_WIFI
#include "shared-bindings/wifi/__init__.h"
#endif

#if CIRCUITPY_OS_GETENV
#include "shared-module/os/__init__.h"
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense, because supervisor/supervisor.mk only compiles this file if CIRCUITPY_WEB_WORKFLOW = 1

Comment on lines +30 to +32
#if !CIRCUITPY_WIFI
#error wifi not in build
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I would rather have this kind of checking in the .mk files. If you do provide these messages, I would make them say CIRCUITPY_WIFI = 0, but this file is being included for clarity. But the corresponding C files should not be being compiled. If they are not, then there would be link errors, which is how things would be caught.

Copy link
Author

Choose a reason for hiding this comment

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

Correct, this is just an optimization for the build to fail at compile time instead of link time, because I'm impatient waiting for builds.
A typical scenario is I'm working on some module, and I sneak in a dependency on another module by including its header file. This compiles fine, but if the other module is not in the build config I happen to be using, I will get a link error. I think it would be hard to check this in .mk files since .mk files don't know what header files C files are including.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you using make -j12 etc.? I'd guess yes.

Copy link
Author

Choose a reason for hiding this comment

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

I need a bigger computer. 😅

Copy link

Choose a reason for hiding this comment

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

Having #error all around the code is a +1 from me.
Linking can take 20s on x64 (-j12) and 4 minutes on my jacked (16% overclock) pi400.

@tannewt
Copy link
Member

tannewt commented Aug 1, 2023

Do we want to merge this or close?

@gneverov
Copy link
Author

gneverov commented Aug 1, 2023

I'm fine with closing it.

@gneverov gneverov closed this Aug 1, 2023
@gneverov gneverov deleted the header_build_check branch November 8, 2023 03:20
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