diff options
| author | Dragos Popescu <31741257+DragosPopse@users.noreply.github.com> | 2023-03-22 12:08:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-22 12:08:45 +0100 |
| commit | 144d034475cd52e969f030d5b4b0864234445e6f (patch) | |
| tree | bef548b1eb11640f9ae6671ae1cee4cabfba8e90 /src | |
| parent | ef3d8bdc428a8248ff108f3a4d5ba0fc866ca9e3 (diff) | |
| parent | e58915e12fdfc499b10adec4f3f0a61c7aa821ea (diff) | |
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'src')
| -rw-r--r-- | src/checker.cpp | 12 | ||||
| -rw-r--r-- | src/checker.hpp | 1 | ||||
| -rw-r--r-- | src/docs_writer.cpp | 12 | ||||
| -rw-r--r-- | src/entity.cpp | 1 | ||||
| -rw-r--r-- | src/main.cpp | 13 | ||||
| -rw-r--r-- | src/parser.cpp | 15 |
6 files changed, 47 insertions, 7 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 1bb437beb..696802e99 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -4447,6 +4447,14 @@ gb_internal DECL_ATTRIBUTE_PROC(foreign_import_decl_attribute) { ac->foreign_import_priority_index = exact_value_to_i64(ev); } return true; + } else if (name == "extra_linker_flags") { + ExactValue ev = check_decl_attribute_value(c, value); + if (ev.kind != ExactValue_String) { + error(elem, "Expected a string value for '%.*s'", LIT(name)); + } else { + ac->extra_linker_flags = ev.value_string; + } + return true; } return false; } @@ -4506,6 +4514,10 @@ gb_internal void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) { if (ac.foreign_import_priority_index != 0) { e->LibraryName.priority_index = ac.foreign_import_priority_index; } + String extra_linker_flags = string_trim_whitespace(ac.extra_linker_flags); + if (extra_linker_flags.len != 0) { + e->LibraryName.extra_linker_flags = extra_linker_flags; + } if (has_asm_extension(fullpath)) { if (build_context.metrics.arch != TargetArch_amd64 || diff --git a/src/checker.hpp b/src/checker.hpp index b82612813..2918b7e83 100644 --- a/src/checker.hpp +++ b/src/checker.hpp @@ -121,6 +121,7 @@ struct AttributeContext { bool set_cold : 1; u32 optimization_mode; // ProcedureOptimizationMode i64 foreign_import_priority_index; + String extra_linker_flags; String objc_class; String objc_name; diff --git a/src/docs_writer.cpp b/src/docs_writer.cpp index 814769f57..7488e955a 100644 --- a/src/docs_writer.cpp +++ b/src/docs_writer.cpp @@ -915,18 +915,20 @@ gb_internal void odin_doc_update_entities(OdinDocWriter *w) { auto entities = array_make<Entity *>(heap_allocator(), 0, w->entity_cache.count); defer (array_free(&entities)); - for (auto const &entry : w->entity_cache) { - array_add(&entities, entry.key); + for (u32 i = 0; i < w->entity_cache.count; i++) { + Entity *e = w->entity_cache.entries[i].key; + array_add(&entities, e); } for (Entity *e : entities) { + GB_ASSERT(e != nullptr); OdinDocTypeIndex type_index = odin_doc_type(w, e->type); gb_unused(type_index); } } - for (auto const &entry : w->entity_cache) { - Entity *e = entry.key; - OdinDocEntityIndex entity_index = entry.value; + for (u32 i = 0; i < w->entity_cache.count; i++) { + Entity *e = w->entity_cache.entries[i].key; + OdinDocEntityIndex entity_index = w->entity_cache.entries[i].value; OdinDocTypeIndex type_index = odin_doc_type(w, e->type); OdinDocEntityIndex foreign_library = 0; diff --git a/src/entity.cpp b/src/entity.cpp index 0c3629b2b..d6f4edece 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -259,6 +259,7 @@ struct Entity { Slice<String> paths; String name; i64 priority_index; + String extra_linker_flags; } LibraryName; i32 Nil; struct { diff --git a/src/main.cpp b/src/main.cpp index 82c20cfe6..bbb28cdf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -278,6 +278,13 @@ gb_internal i32 linker_stage(lbGenerator *gen) { } } + for (Entity *e : gen->foreign_libraries) { + GB_ASSERT(e->kind == Entity_LibraryName); + if (e->LibraryName.extra_linker_flags.len != 0) { + lib_str = gb_string_append_fmt(lib_str, " %.*s", LIT(e->LibraryName.extra_linker_flags)); + } + } + if (build_context.build_mode == BuildMode_DynamicLibrary) { link_settings = gb_string_append_fmt(link_settings, " /DLL"); } else { @@ -449,6 +456,12 @@ gb_internal i32 linker_stage(lbGenerator *gen) { } } + for (Entity *e : gen->foreign_libraries) { + GB_ASSERT(e->kind == Entity_LibraryName); + if (e->LibraryName.extra_linker_flags.len != 0) { + lib_str = gb_string_append_fmt(lib_str, " %.*s", LIT(e->LibraryName.extra_linker_flags)); + } + } gbString object_files = gb_string_make(heap_allocator(), ""); defer (gb_string_free(object_files)); diff --git a/src/parser.cpp b/src/parser.cpp index 0d9fad8c7..07afc56d6 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1434,7 +1434,7 @@ gb_internal Token expect_closing_brace_of_field_list(AstFile *f) { return token; } bool ok = true; - if (!f->allow_newline) { + if (f->allow_newline) { ok = !skip_possible_newline(f); } if (ok && allow_token(f, Token_Semicolon)) { @@ -3191,6 +3191,15 @@ gb_internal Ast *parse_foreign_block(AstFile *f, Token token) { return decl; } +gb_internal void print_comment_group(CommentGroup *group) { + if (group) { + for (Token const &token : group->list) { + gb_printf_err("%.*s\n", LIT(token.string)); + } + gb_printf_err("\n"); + } +} + gb_internal Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup *docs) { bool is_mutable = true; @@ -3232,6 +3241,8 @@ gb_internal Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup * values.allocator = heap_allocator(); } + CommentGroup *end_comment = f->lead_comment; + if (f->expr_level >= 0) { if (f->curr_token.kind == Token_CloseBrace && f->curr_token.pos.line == f->prev_token.pos.line) { @@ -3252,7 +3263,7 @@ gb_internal Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup * } } - return ast_value_decl(f, names, type, values, is_mutable, docs, f->line_comment); + return ast_value_decl(f, names, type, values, is_mutable, docs, end_comment); } gb_internal Ast *parse_simple_stmt(AstFile *f, u32 flags) { |