From 9e0b69312b949f6f0e1e1851db3ecb79be25cfa1 Mon Sep 17 00:00:00 2001 From: vassvik Date: Fri, 10 Nov 2017 21:31:13 +0100 Subject: Fixed foreign import for linux. Modified .gitignore to ignore temp files and files in shared/. Added a Makefile for linux --- src/parser.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index f81bb1a39..1c90bf274 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -4880,7 +4880,22 @@ bool determine_path_from_string(Parser *p, AstNode *node, String base_dir, Strin syntax_error(node, "Unknown library collection: `%.*s`", LIT(collection_name)); return false; } + } else { +#if !defined(GB_SYSTEM_WINDOWS) + // @NOTE(vassvik): foreign imports of shared libraries that are not in the system collection on + // linux/mac have to be local to the executable for consistency with shared libraries. + // Unix does not have a concept of "import library" for shared/dynamic libraries, + // so we need to pass the relative path to the linker, and add the current + // working directory of the exe to the library search paths. + // Static libraries can be linked directly with the full pathname + // + if (node->kind == AstNode_ForeignImportDecl && string_has_extension(file_str, str_lit("so"))) { + *path = file_str; + return true; + } +#endif } + String fullpath = string_trim_whitespace(get_fullpath_relative(a, base_dir, file_str)); *path = fullpath; -- cgit v1.2.3