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

Add options to disable some newlibfunctionalities #250

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

Conversation

fjtrujy
Copy link
Member

@fjtrujy fjtrujy commented Nov 29, 2024

Description

The main scope of this PR is to allow the user to disable some concrete newlib/POSIX features to save RAM.
This is just for advanced users that understand what is going under the crt0 and libcglue initialization.

I have added a new example where we see how we can reduce a dummy hello world.

int main(int argc, char** argv) {
    while(1) { printf("Hello World!\n"); }
    return 0;
}

From EBOOT.PBP with 126664 bytes:

-rw-r--r--  1 fjtrujy  staff  126664 Nov 29 17:29 EBOOT.PBP
-rw-r--r--  1 fjtrujy  staff     328 Nov 29 17:27 Makefile.sample
-rw-r--r--  1 fjtrujy  staff     324 Nov 29 17:29 PARAM.SFO
-rwxr-xr-x  1 fjtrujy  staff  126300 Nov 29 17:29 light_size.elf
-rw-r--r--  1 fjtrujy  staff    1167 Nov 29 17:29 main.c
-rw-r--r--  1 fjtrujy  staff    2140 Nov 29 17:29 main.o

To EBOOT.PBP with 50532 bytes:

-rw-r--r--  1 fjtrujy  staff  50532 Nov 29 18:22 EBOOT.PBP
-rw-r--r--  1 fjtrujy  staff    328 Nov 29 18:31 Makefile.sample
-rw-r--r--  1 fjtrujy  staff    324 Nov 29 18:22 PARAM.SFO
-rwxr-xr-x  1 fjtrujy  staff  50168 Nov 29 18:22 light_size.elf
-rw-r--r--  1 fjtrujy  staff   1176 Nov 29 18:31 main.c
-rw-r--r--  1 fjtrujy  staff   5052 Nov 29 18:22 main.o

Just putting in your main.c file:

#include <sys/socket.h>
#include <errno.h>

PSP_DISABLE_NEWLIB_PIPE_SUPPORT()
PSP_DISABLE_NEWLIB_SOCKET_SUPPORT()
PSP_DISABLE_NEWLIB_TIMEZONE_SUPPORT()
PSP_DISABLE_NEWLIB_CWD_SUPPORT()
PSP_DISABLE_AUTOSTART_PTHREAD()

Cheers

- Option to disable pipe support
- Option to disable socker support
- Option to disable timezone support
- Option to disable cwd support
@fjtrujy fjtrujy force-pushed the improveLibCWeakSuport branch from feed6de to 091ef89 Compare November 29, 2024 17:32
Copy link
Member

@diamant3 diamant3 left a comment

Choose a reason for hiding this comment

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

This is a really nice improvement, fjtrujy! approved to me.

Just a side question, Can you do it using a makefile instead of putting it in a code?

@sharkwouter
Copy link
Member

Honestly, I'd argue it is nicer to have it in the code. This looks like a fine change to me, but I did not test it yet.

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.

3 participants