BB_CI def and some fixes

This commit is contained in:
David Gonzalez Martin 2025-02-12 09:47:55 -06:00 committed by David
parent f9bfbf9e8f
commit cf508c2b9c
3 changed files with 32 additions and 17 deletions

View File

@ -55,7 +55,7 @@ jobs:
needs: generate-config
permissions: write-all
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [ x86_64-linux-znver4 ]
BIRTH_BUILD_TYPE: ${{ fromJSON(needs.generate-config.outputs.BIRTH_BUILD_TYPES) }}

View File

@ -1451,7 +1451,7 @@ fn EncodingBatch encoding_batch_from_scalar(EncodingScalar scalar)
batch.opcode.values[1][i] = scalar.opcode.bytes[1];
batch.opcode.values[2][i] = scalar.opcode.bytes[2];
batch.opcode.extension[i] = scalar.opcode.extension;
batch.opcode.plus_register |= scalar.opcode.plus_register << i;
batch.opcode.plus_register |= (u64)scalar.opcode.plus_register << i;
}
for (u64 i = 0; i < array_length(batch.opcode.lengths); i += 1)
@ -1889,7 +1889,7 @@ fn u8 encoding_test_instruction_batches(Arena* arena, TestDataset dataset, Encod
VirtualBuffer(u8) clang_pipe_buffer = {};
vb_ensure_capacity(&clang_pipe_buffer, 1024*1024);
llvm_initialize_macro(X86, _null_prefix_());
let(disassembler, LLVMCreateDisasmCPU("x86_64-freestanding", "znver5", 0, 0, 0, 0));
let(disassembler, LLVMCreateDisasmCPU("x86_64-freestanding", "znver4", 0, 0, 0, 0));
u64 disassembly_options = LLVMDisassembler_Option_AsmPrinterVariant | LLVMDisassembler_Option_PrintImmHex;
if (!LLVMSetDisasmOptions(disassembler, disassembly_options))
{
@ -4917,12 +4917,17 @@ int main(int argc, char** argv, char** envp)
Arena* arena = arena_initialize_default(MB(2));
assemble_file(arena, strlit("large_assembly.s"));
// TestDataset dataset = construct_test_cases();
// EncodingTestOptions options = {
// .scalar = 1,
// .wide = 1,
// };
// u8 result = encoding_test_instruction_batches(arena, dataset, options);
int result = 0;
return 0;
if (BB_CI)
{
TestDataset dataset = construct_test_cases();
EncodingTestOptions options = {
.scalar = 1,
.wide = 1,
};
result = encoding_test_instruction_batches(arena, dataset, options);
}
return result;
}

24
build.c
View File

@ -523,6 +523,15 @@ fn void compile_program(Arena* arena, CompileOptions options)
} break;
}
if (BB_CI)
{
add_arg("-DBB_CI=1");
}
else
{
add_arg("-DBB_CI=0");
}
// TODO: careful. If handing binaries built by CI to people, we need to be specially careful about this
if (c_compiler == C_COMPILER_MSVC)
{
@ -707,7 +716,7 @@ fn void compile_program(Arena* arena, CompileOptions options)
char* argv_buffer[4096];
argv_buffer[0] = llvm_config_c;
argv_buffer[1] = "--libs";
u32 arg_i = 2;
u32 local_arg_i = 2;
String llvm_components = { .pointer = buffer, .length = length };
u32 i = 0;
@ -719,14 +728,14 @@ fn void compile_program(Arena* arena, CompileOptions options)
u64 argument_length = unlikely(there_is_space) ? space_index : slice.length;
String argument_slice = s_get_slice(u8, slice, 0, argument_length - !there_is_space);
argv_buffer[arg_i] = string_to_c(arena_duplicate_string(arena, argument_slice));
arg_i += 1;
argv_buffer[local_arg_i] = string_to_c(arena_duplicate_string(arena, argument_slice));
local_arg_i += 1;
i += argument_length + there_is_space;
}
argv_buffer[arg_i] = 0;
arg_i += 1;
argv_buffer[local_arg_i] = 0;
local_arg_i += 1;
length = 0;
@ -739,7 +748,7 @@ fn void compile_program(Arena* arena, CompileOptions options)
},
.debug = options.flags.debug,
};
CStringSlice arguments = { .pointer = argv_buffer, .length = arg_i };
CStringSlice arguments = { .pointer = argv_buffer, .length = local_arg_i };
RunCommandResult result = run_command(arena, arguments, environment_pointer, run_options);
let(success, result.termination_kind == PROCESS_TERMINATION_EXIT && result.termination_code == 0);
if (!success)
@ -749,9 +758,10 @@ fn void compile_program(Arena* arena, CompileOptions options)
i = 0;
String llvm_libraries = { .pointer = buffer, .length = length };
while (i < length)
{
String slice = s_get_slice(u8, llvm_components, i, llvm_components.length);
String slice = s_get_slice(u8, llvm_libraries, i, llvm_libraries.length);
u64 space_index = string_first_ch(slice, ' ');
u8 there_is_space = space_index != STRING_NO_MATCH;
u64 argument_length = unlikely(there_is_space) ? space_index : slice.length;