From c9889582a7f56b3bfdca455a8d84167f688cd3c8 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 27 May 2024 17:45:22 -0400 Subject: Fix up some import and -fPIC stuff --- compile.c | 8 ++++---- tomo.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compile.c b/compile.c index da48521a..d8a6f445 100644 --- a/compile.c +++ b/compile.c @@ -1930,7 +1930,7 @@ CORD compile(env_t *env, ast_t *ast) else return Match(ast, InlineCCode)->code; } - case Use: return CORD_EMPTY; + case Use: code_err(ast, "Compiling 'use' as expression!"); case LinkerDirective: code_err(ast, "Linker directives are not supported yet"); case Extern: code_err(ast, "Externs are not supported as expressions"); case TableEntry: code_err(ast, "Table entries should not be compiled directly"); @@ -2218,13 +2218,13 @@ module_code_t compile_file(ast_t *ast) if (!is_constant(env, decl->value)) code_err(decl->value, "This value is not a valid constant initializer."); - if (is_private) { + if (decl->value->tag == Use) { + assert(compile_statement(env, stmt->ast) == CORD_EMPTY); + } else if (is_private) { env->code->staticdefs = CORD_all( env->code->staticdefs, "static ", compile_type(env, t), " $", decl_name, " = ", compile(env, decl->value), ";\n"); - } else if (decl->value->tag == Use) { - assert(compile_statement(env, stmt->ast) == CORD_EMPTY); } else { env->code->fndefs = CORD_all( env->code->fndefs, diff --git a/tomo.c b/tomo.c index 0fcf0b78..0f623418 100644 --- a/tomo.c +++ b/tomo.c @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) cflags = getenv("CFLAGS"); if (!cflags) - cflags = heap_strf("%s %s -ggdb -I./include -D_DEFAULT_SOURCE", cconfig, optimization); + cflags = heap_strf("%s %s -fPIC -ggdb -I./include -D_DEFAULT_SOURCE", cconfig, optimization); ldflags = "-Wl,-rpath '-Wl,$ORIGIN' -L/usr/local/lib -L."; -- cgit v1.2.3