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

fix: don't add symbols from libc if dynamic #16

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/cjit.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static int cjit_cli(TCCState *TCC)
{
char *line = NULL;
size_t len = 0;
ssize_t read;
ssize_t rd;
int res = 0;
const char intro[]="#include <stdio.h>\n#include <stdlib.h>\nint main(int argc, char **argv) {\n";
char *code = malloc(sizeof(intro));
Expand All @@ -116,8 +116,8 @@ static int cjit_cli(TCCState *TCC)
if (isatty(fileno(stdin)))
printf("cjit> ");
fflush(stdout);
read = getline(&line, &len, stdin);
if (read == -1) {
rd = getline(&line, &len, stdin);
if (rd == -1) {
/* This is CTRL + D */
code = realloc(code, strlen(code) + 4);
if (!code) {
Expand Down Expand Up @@ -233,12 +233,15 @@ int main(int argc, char **argv) {
// set output in memory for just in time execution
tcc_set_output_type(TCC, TCC_OUTPUT_MEMORY);


#if defined(LIBC_MUSL)
// simple temporary exports for hello world
// tcc_add_symbol(TCC, "exit", &return);
tcc_add_symbol(TCC, "stdout", &stdout);
tcc_add_symbol(TCC, "stderr", &stderr);
tcc_add_symbol(TCC, "exit", &exit);
tcc_add_symbol(TCC, "fprintf", &fprintf);
tcc_add_symbol(TCC, "printf", &printf);
#endif

if (argc == 0) {
printf("No input file: running in interactive mode\n");
Expand Down