瀏覽代碼

Linker on MacOS and GNU/Linux now includes foreign_system_libraries. Fixed foreign_system_library not respecting 'when' condition.

Zachary Pierson 8 年之前
父節點
當前提交
73c5c5d5d3
共有 2 個文件被更改,包括 14 次插入13 次删除
  1. 13 3
      src/checker.c
  2. 1 10
      src/main.c

+ 13 - 3
src/checker.c

@@ -1488,6 +1488,19 @@ void check_collect_entities(Checker *c, AstNodeArray nodes, bool is_file_scope)
 				continue;
 			}
 
+			if (fl->cond != NULL) {
+				Operand operand = {Addressing_Invalid};
+				check_expr(c, &operand, fl->cond);
+				if (operand.mode != Addressing_Constant || !is_type_boolean(operand.type)) {
+					error_node(fl->cond, "Non-constant boolean `when` condition");
+					continue;
+				}
+				if (operand.value.kind == ExactValue_Bool &&
+					!operand.value.value_bool) {
+					continue;
+				}
+			}
+
 			DelayedDecl di = {c->context.scope, decl};
 			array_add(&c->delayed_foreign_libraries, di);
 		case_end;
@@ -1853,6 +1866,3 @@ void check_parsed_files(Checker *c) {
 	map_scope_destroy(&file_scopes);
 
 }
-
-
-

+ 1 - 10
src/main.c

@@ -375,9 +375,8 @@ int main(int argc, char **argv) {
 	char lib_str_buf[1024] = {0};
 	for_array(i, ir_gen.module.foreign_library_paths) {
 		String lib = ir_gen.module.foreign_library_paths.e[i];
-		// gb_printf_err("Linking lib: %.*s\n", LIT(lib));
 		isize len = gb_snprintf(lib_str_buf, gb_size_of(lib_str_buf),
-		                        " \"%.*s\"", LIT(lib));
+		                        " -l%.*s ", LIT(lib));
 		lib_str = gb_string_appendc(lib_str, lib_str_buf);
 	}
 
@@ -410,14 +409,6 @@ int main(int argc, char **argv) {
 		linker = "clang";
 	#endif
 
-	printf("Libs: %s\n", lib_str);
-
-	// TODO(zangent): I'm not sure what to do with lib_str.
-	//   I'll have to look at the format that the libraries are listed to determine what to do.
-	lib_str = "";
-
-
-
 	exit_code = system_exec_command_line_app("ld-link", true,
 		"%s \"%.*s\".o -o \"%.*s%s\" %s "
 		"-lc "