Skip to content

Parser-less build mode #976

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
bnoordhuis opened this issue Mar 15, 2025 · 3 comments · Fixed by #1021
Closed

Parser-less build mode #976

bnoordhuis opened this issue Mar 15, 2025 · 3 comments · Fixed by #1021
Labels
enhancement New feature or request

Comments

@bnoordhuis
Copy link
Contributor

Something touched upon recently by @chqrlie: make it possible to build qjs without the JS parser and bytecode generator.

Such builds can only execute bytecode read with JS_ReadObject() but you get a substantially smaller library in return. The parser makes up 15-25% of the library, depending on how you count.

Useful for embedded environments. Cuts down on attack surface.

A challenge is that JSON.parse() uses bits and pieces of the parser.

@bnoordhuis bnoordhuis added the enhancement New feature or request label Mar 15, 2025
@TooTallNate
Copy link
Contributor

Sounds interesting! I assume eval() and new Function() would also not be available in these builds? Would the JSON.parse() part also be a limitation of these builds or would solving that be a prereq for this feature?

@bnoordhuis
Copy link
Contributor Author

No eval() and new Function() indeed. JSON.parse() should keep working though.

bnoordhuis added a commit to bnoordhuis/quickjs that referenced this issue Apr 8, 2025
Add a QJS_ENABLE_PARSER build option that enables/disables the parser.

Useful if you want to execute bytecode but not parse source code, e.g.,
for hardening reasons, or due to running in a constrained environment.

Shrinks a release build by about 15%.

Fixes: quickjs-ng#976
@bnoordhuis
Copy link
Contributor Author

#1021 for people who want to test it.

bnoordhuis added a commit to bnoordhuis/quickjs that referenced this issue Apr 10, 2025
Add a QJS_DISABLE_PARSER build option that disables the JS source code
parser. The JSON parser is unaffected.

Useful if you want to execute bytecode but not parse source code, e.g.,
for hardening reasons, or due to running in a constrained environment.

Shrinks a release build by about 15%.

Fixes: quickjs-ng#976
bnoordhuis added a commit that referenced this issue Apr 10, 2025
Add a QJS_DISABLE_PARSER build option that disables the JS source code
parser. The JSON parser is unaffected.

Useful if you want to execute bytecode but not parse source code, e.g.,
for hardening reasons, or due to running in a constrained environment.

Shrinks a release build by about 15%.

Fixes: #976
graham pushed a commit to graham/quickjs that referenced this issue Apr 11, 2025
Add a QJS_DISABLE_PARSER build option that disables the JS source code
parser. The JSON parser is unaffected.

Useful if you want to execute bytecode but not parse source code, e.g.,
for hardening reasons, or due to running in a constrained environment.

Shrinks a release build by about 15%.

Fixes: quickjs-ng#976
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants