More serious LLVM linking
All checks were successful
All checks were successful
This commit is contained in:
parent
a6315a388f
commit
f24ec2864c
@ -832,6 +832,8 @@ LLVMIntrinsicIndex = enum
|
||||
va_copy,
|
||||
}
|
||||
|
||||
[extern] LLVMContextCreate = fn [cc(c)] () &LLVMContext;
|
||||
|
||||
ModuleLLVM = struct
|
||||
{
|
||||
context: &LLVMContext,
|
||||
@ -2612,6 +2614,7 @@ parse = fn (module: &Module) void
|
||||
|
||||
emit = fn (module: &Module) void
|
||||
{
|
||||
>context = LLVMContextCreate();
|
||||
}
|
||||
|
||||
compile = fn (arena: &Arena, options: CompileOptions) void
|
||||
|
@ -97,6 +97,7 @@ fn void compile(Arena* arena, Options options)
|
||||
.library_directories = options.library_directories,
|
||||
.library_names = options.library_names,
|
||||
.library_paths = options.library_paths,
|
||||
.link_libcpp = options.link_libcpp,
|
||||
.target = options.target,
|
||||
.build_mode = options.build_mode,
|
||||
.has_debug_info = options.has_debug_info,
|
||||
@ -250,6 +251,13 @@ fn String compile_file(Arena* arena, Compile options)
|
||||
library_list = library_list(space + 1);
|
||||
}
|
||||
|
||||
library_buffer[library_count] = string_literal("gcc");
|
||||
library_count += 1;
|
||||
library_buffer[library_count] = string_literal("gcc_s");
|
||||
library_count += 1;
|
||||
library_buffer[library_count] = string_literal("m");
|
||||
library_count += 1;
|
||||
|
||||
library_names = { library_buffer, library_count };
|
||||
}
|
||||
else if (base_name.equal(string_literal("c_abi")))
|
||||
@ -266,6 +274,7 @@ fn String compile_file(Arena* arena, Compile options)
|
||||
.library_paths = library_paths,
|
||||
.library_names = library_names,
|
||||
.library_directories = library_directories,
|
||||
.link_libcpp = is_compiler,
|
||||
.target = {
|
||||
.cpu = CPUArchitecture::x86_64,
|
||||
.os = OperatingSystem::linux_,
|
||||
|
@ -1213,10 +1213,13 @@ struct Module
|
||||
String name;
|
||||
String path;
|
||||
String executable;
|
||||
|
||||
Slice<String> objects;
|
||||
Slice<String> library_directories;
|
||||
Slice<String> library_names;
|
||||
Slice<String> library_paths;
|
||||
bool link_libc = true;
|
||||
bool link_libcpp = false;
|
||||
|
||||
Target target;
|
||||
BuildMode build_mode;
|
||||
@ -1288,6 +1291,7 @@ struct Options
|
||||
Slice<String> library_paths;
|
||||
Slice<String> library_names;
|
||||
Slice<String> library_directories;
|
||||
bool link_libcpp;
|
||||
Target target;
|
||||
BuildMode build_mode;
|
||||
bool has_debug_info;
|
||||
|
@ -8326,11 +8326,6 @@ fn void link(Module* module)
|
||||
assert(module->executable.pointer[module->executable.length] == 0);
|
||||
builder.add((char*)module->executable.pointer);
|
||||
|
||||
for (String object: module->objects)
|
||||
{
|
||||
builder.add(arena, object);
|
||||
}
|
||||
|
||||
for (String library_directory: module->library_directories)
|
||||
{
|
||||
String parts[] = {
|
||||
@ -8340,20 +8335,6 @@ fn void link(Module* module)
|
||||
builder.add(arena, arena_join_string(arena, array_to_slice(parts)));
|
||||
}
|
||||
|
||||
for (String library_path: module->library_paths)
|
||||
{
|
||||
builder.add(arena, library_path);
|
||||
}
|
||||
|
||||
for (String library_name: module->library_names)
|
||||
{
|
||||
String parts[] = {
|
||||
string_literal("-l"),
|
||||
library_name,
|
||||
};
|
||||
builder.add(arena, arena_join_string(arena, array_to_slice(parts)));
|
||||
}
|
||||
|
||||
String candidate_library_paths[] = {
|
||||
string_literal("/usr/lib"),
|
||||
string_literal("/usr/lib/x86_64-linux-gnu"),
|
||||
@ -8391,8 +8372,29 @@ fn void link(Module* module)
|
||||
builder.add((char*)arena_join_string(arena, array_to_slice(parts)).pointer);
|
||||
}
|
||||
|
||||
auto link_libcpp = false;
|
||||
if (link_libcpp)
|
||||
builder.add("-L/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1");
|
||||
builder.add("-L/usr/lib/gcc/x86_64-linux-gnu/13");
|
||||
|
||||
for (String object: module->objects)
|
||||
{
|
||||
builder.add(arena, object);
|
||||
}
|
||||
|
||||
for (String library_path: module->library_paths)
|
||||
{
|
||||
builder.add(arena, library_path);
|
||||
}
|
||||
|
||||
for (String library_name: module->library_names)
|
||||
{
|
||||
String parts[] = {
|
||||
string_literal("-l"),
|
||||
library_name,
|
||||
};
|
||||
builder.add(arena, arena_join_string(arena, array_to_slice(parts)));
|
||||
}
|
||||
|
||||
if (module->link_libcpp)
|
||||
{
|
||||
builder.add("-lstdc++");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user