littlekernel / lk

LK embedded kernel
MIT License
3.12k stars 613 forks source link

Why is "WITH_LIB_CONSOLE" not defined anywhere? #247

Open zinahe opened 5 years ago

zinahe commented 5 years ago

Hi,

I have done a full scan of the code trying to understand WITH_LIB_CONSOLE. I have have seen many cases where it is being tested for conditional compilation of blocks of code. But it doesn't seem to be defined anywhere. Not in any header file; nor in any make file; not even in app/shell which seems to me the primary user of lib/console. What gives ?

Thanks,

travisg commented 5 years ago

The WITH_* #defines are set by the build system when that particular module is included in the build. It's not used a lot, but WITH_LIB_CONSOLE is tested in lots of places to determine if it should add a shell function.

On Sun, Jun 30, 2019 at 7:25 PM Zinahe notifications@github.com wrote:

Hi,

I have done a full scan of the code trying to understand WITH_LIB_CONSOLE. I have have seen many cases where it is being tested for conditional compilation of blocks of code. But it doesn't seem to be defined anywhere. Not in any header file; nor in any make file; not even in app/shell which seems to me the primary user of lib/console. What gives ?

Thanks,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/littlekernel/lk/issues/247?email_source=notifications&email_token=AAAX3LF67MLA3HC4TWATE7LP5FTKNA5CNFSM4H4OD3P2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4Q5DZQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAX3LAJNEFT3HODAJYZ7D3P5FTKNANCNFSM4H4OD3PQ .

travisg commented 5 years ago

If you look in build-/config.h it's set there, the config.h file(s) are generated by the build system.

On Sun, Jun 30, 2019 at 7:27 PM Travis Geiselbrecht travisg@gmail.com wrote:

The WITH_* #defines are set by the build system when that particular module is included in the build. It's not used a lot, but WITH_LIB_CONSOLE is tested in lots of places to determine if it should add a shell function.

On Sun, Jun 30, 2019 at 7:25 PM Zinahe notifications@github.com wrote:

Hi,

I have done a full scan of the code trying to understand WITH_LIB_CONSOLE. I have have seen many cases where it is being tested for conditional compilation of blocks of code. But it doesn't seem to be defined anywhere. Not in any header file; nor in any make file; not even in app/shell which seems to me the primary user of lib/console. What gives ?

Thanks,

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/littlekernel/lk/issues/247?email_source=notifications&email_token=AAAX3LF67MLA3HC4TWATE7LP5FTKNA5CNFSM4H4OD3P2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4Q5DZQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAX3LAJNEFT3HODAJYZ7D3P5FTKNANCNFSM4H4OD3PQ .

zinahe commented 5 years ago

@travisg,

Thanks for the quick response. So, it's auto-generated at build time. That explains why I was never able to pinpoint its define in the source tree. Basically, I'm trying find ways to generate the smallest possible binary for a blinky app on an STM32F401 board. One that seemed help so far is GLOBAL_COMPILEFLAGS += -DDISABLE_DEBUG_OUTPUT=1 in the project/.mk file. That shaved off a whopping 8k from the bin file. I'd be grateful for any pointers.

travisg commented 5 years ago

Ah a project with just an app that does the blinky, and the DISABLE_DEBUG_OUTPUT should be pretty close. Also, set it as GLOBAL_DEFINES += DISABLE_DEBUG_OUTPUT=1. That gets more cleanly added to the config.h files, though it should end up with about the same thing.

Removing debug output kills printf, which generally takes out a sizeable chunk of stuff. IIRC, the smallest build with the kernel is around 10K or so. The ST libraries are not great though and tend to add a fair amount of bloat, though they usually compile out if not called.

On Sun, Jun 30, 2019 at 7:56 PM Zinahe notifications@github.com wrote:

@travisg https://github.com/travisg,

Thanks for the quick response. So, it's auto-generated at build time. That explains why I was never able to pinpoint its define in the source tree. Basically, I'm trying find ways to generate the smallest possible binary for a blinky app on an STM32F401 board. One that seemed help so far is GLOBAL_COMPILEFLAGS += -DDISABLE_DEBUG_OUTPUT=1 in the project/.mk file. That shaved off a whopping 8k from the bin file. I'd be grateful for any pointers.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/littlekernel/lk/issues/247?email_source=notifications&email_token=AAAX3LBPIFHVM56ZNAUYTFTP5FW6ZA5CNFSM4H4OD3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY43LBI#issuecomment-507098501, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAX3LF2HM6HSXECSBZN3ATP5FW6ZANCNFSM4H4OD3PQ .

travisg commented 5 years ago

Oh, set debug level to 0 as well, that removes almost all of the asserts in the system. You can do it with DEBUG:=0 in the project file.

On Sun, Jun 30, 2019 at 8:33 PM Travis Geiselbrecht travisg@gmail.com wrote:

Ah a project with just an app that does the blinky, and the DISABLE_DEBUG_OUTPUT should be pretty close. Also, set it as GLOBAL_DEFINES += DISABLE_DEBUG_OUTPUT=1. That gets more cleanly added to the config.h files, though it should end up with about the same thing.

Removing debug output kills printf, which generally takes out a sizeable chunk of stuff. IIRC, the smallest build with the kernel is around 10K or so. The ST libraries are not great though and tend to add a fair amount of bloat, though they usually compile out if not called.

On Sun, Jun 30, 2019 at 7:56 PM Zinahe notifications@github.com wrote:

@travisg https://github.com/travisg,

Thanks for the quick response. So, it's auto-generated at build time. That explains why I was never able to pinpoint its define in the source tree. Basically, I'm trying find ways to generate the smallest possible binary for a blinky app on an STM32F401 board. One that seemed help so far is GLOBAL_COMPILEFLAGS += -DDISABLE_DEBUG_OUTPUT=1 in the project/.mk file. That shaved off a whopping 8k from the bin file. I'd be grateful for any pointers.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/littlekernel/lk/issues/247?email_source=notifications&email_token=AAAX3LBPIFHVM56ZNAUYTFTP5FW6ZA5CNFSM4H4OD3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY43LBI#issuecomment-507098501, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAX3LF2HM6HSXECSBZN3ATP5FW6ZANCNFSM4H4OD3PQ .