Browse Source

Disallow `@(thread_local)` on wasm targets

gingerBill 3 years ago
parent
commit
410b85b5c7
3 changed files with 9 additions and 2 deletions
  1. 4 0
      src/check_decl.cpp
  2. 4 1
      src/check_stmt.cpp
  3. 1 1
      src/checker.cpp

+ 4 - 0
src/check_decl.cpp

@@ -1130,6 +1130,10 @@ void check_global_variable_decl(CheckerContext *ctx, Entity *&e, Ast *type_expr,
 	}
 	ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix);
 
+	if (is_arch_wasm() && e->Variable.thread_local_model.len != 0) {
+		error(e->token, "@(thread_local) is not supported for this target platform");
+	}
+
 	String context_name = str_lit("variable declaration");
 
 	if (type_expr != nullptr) {

+ 4 - 1
src/check_stmt.cpp

@@ -2152,7 +2152,6 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
 					e->state = EntityState_Resolved;
 				}
 				ac.link_name = handle_link_name(ctx, e->token, ac.link_name, ac.link_prefix);
-				e->Variable.thread_local_model = ac.thread_local_model;
 
 				if (ac.link_name.len > 0) {
 					e->Variable.link_name = ac.link_name;
@@ -2182,6 +2181,10 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
 					}
 					e->Variable.thread_local_model = ac.thread_local_model;
 				}
+
+				if (is_arch_wasm() && e->Variable.thread_local_model.len != 0) {
+					error(e->token, "@(thread_local) is not supported for this target platform");
+				}
 				
 
 				if (ac.is_static && ac.thread_local_model != "") {

+ 1 - 1
src/checker.cpp

@@ -2271,7 +2271,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
 		str_lit("args__"),
 	);
 
-	FORCE_ADD_RUNTIME_ENTITIES(build_context.no_crt,
+	FORCE_ADD_RUNTIME_ENTITIES((build_context.no_crt && !is_arch_wasm()),
 		// NOTE(bill): Only if these exist
 		str_lit("_tls_index"),
 		str_lit("_fltused"),