The checked-arithmetic helpers every generated module carries no longer test __TINYC__.
3948 lines
152 KiB
C
3948 lines
152 KiB
C
/* Generated by zi2c from compiler_backend_cache.zi. */
|
|
#define ZIRAN_COMPILER_BACKEND_CACHE_H_SOURCE 1
|
|
#include <stdbool.h>
|
|
#include "zir_bounds.h"
|
|
#include "zir_string.h"
|
|
#include "zir_vec.h"
|
|
#include "compiler_backend_cache.h"
|
|
#ifndef ZIRAN_HELPER_ZiShl32
|
|
#define ZIRAN_HELPER_ZiShl32
|
|
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__OPTIMIZE__)
|
|
#define ZiShl32(a, s, w) __extension__ ({ uint32_t __zi_a = (a); uint64_t __zi_s = (s); if(__zi_s >= (uint64_t)(w)) abort(); (uint32_t)(__zi_a << __zi_s); })
|
|
#else
|
|
static inline uint32_t ZiShl32(uint32_t a, uint64_t s, int w) {
|
|
if(s >= (uint64_t)w) abort();
|
|
return (uint32_t)(a << s);
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef ZIRAN_HELPER_ZiShrU32
|
|
#define ZIRAN_HELPER_ZiShrU32
|
|
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__OPTIMIZE__)
|
|
#define ZiShrU32(a, s, w) __extension__ ({ uint32_t __zi_a = (a); uint64_t __zi_s = (s); if(__zi_s >= (uint64_t)(w)) abort(); __zi_a >> __zi_s; })
|
|
#else
|
|
static inline uint32_t ZiShrU32(uint32_t a, uint64_t s, int w) {
|
|
if(s >= (uint64_t)w) abort();
|
|
return a >> s;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
#ifndef ZIRAN_HELPER_ZiShrU64
|
|
#define ZIRAN_HELPER_ZiShrU64
|
|
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__OPTIMIZE__)
|
|
#define ZiShrU64(a, s, w) __extension__ ({ uint64_t __zi_a = (a); uint64_t __zi_s = (s); if(__zi_s >= (uint64_t)(w)) abort(); __zi_a >> __zi_s; })
|
|
#else
|
|
static inline uint64_t ZiShrU64(uint64_t a, uint64_t s, int w) {
|
|
if(s >= (uint64_t)w) abort();
|
|
return a >> s;
|
|
}
|
|
#endif
|
|
#endif
|
|
__type_c53c2d7c4913dc02 ProfileNames = {0};
|
|
|
|
HashState
|
|
compiler_backend_cache_HashNew(void)
|
|
{
|
|
HashState result = {0};
|
|
zir_f_36a3c20ab8e249b6_ShaBegin((void*)(&(result)));
|
|
return result;
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_HashByte(HashState* hash, uint8_t value)
|
|
{
|
|
uint8_t byte = value;
|
|
zir_f_36a3c20ab8e249b6_ShaAdd((void*)(hash), (uint8_t*)(&(byte)), 1);
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_HashBytes(HashState* hash, String value)
|
|
{
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(value).length; it_index++) {
|
|
uint8_t byte = (uint8_t)value.data[it_index];
|
|
compiler_backend_cache_HashByte(hash, byte);
|
|
}
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_HashInteger(HashState* hash, uint64_t value)
|
|
{
|
|
uint8_t bytes[8];
|
|
for (int64_t index = 0LL; index <= 7LL; index++) {
|
|
uint8_t* value_0 = &(bytes[index]);
|
|
uint8_t value_1 = (uint8_t)((ZiShrU64(value, (uint64_t)((uint64_t)(((int64_t)(UINT64_C(8) * (uint64_t)index)))), 64)));
|
|
(*value_0) = value_1;
|
|
}
|
|
Slice value_2 = {bytes, 8};
|
|
Slice value_3 = value_2;
|
|
compiler_backend_cache_HashBytes(hash, StringView((const char *)(value_3).data, (size_t)(value_3).length));
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_HashText(HashState* hash, String value)
|
|
{
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)((int64_t)(value).length));
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(value).length; it_index++) {
|
|
uint8_t byte = (uint8_t)value.data[it_index];
|
|
compiler_backend_cache_HashByte(hash, byte);
|
|
}
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_HashFinish(HashState* hash, Digest* output)
|
|
{
|
|
zir_f_36a3c20ab8e249b6_ShaEnd((void*)(hash), output->bytes);
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_ProfileCount(String name)
|
|
{
|
|
uint8_t* pointer = compiler_backend_cache_ProfileName(name);
|
|
if (pointer != ((void *)0)) {
|
|
zir_f_36a3c20ab8e249b6_ProfileCountForeign(pointer);
|
|
}
|
|
}
|
|
|
|
uint8_t*
|
|
compiler_backend_cache_ProfileName(String name)
|
|
{
|
|
for (int64_t it_index = 0LL; it_index < ProfileNames.count; it_index++) {
|
|
String value = ZIRAN_VEC_INDEX((ProfileNames).data, (ProfileNames).count, it_index);
|
|
if (StringEqual(value, name)) {
|
|
View* descriptor = (View*)(&(value));
|
|
return descriptor->data;
|
|
}
|
|
}
|
|
void* value = zir_f_36a3c20ab8e249b6_AllocateRaw(1, (size_t)(((int64_t)((uint64_t)((int64_t)(name).length) + UINT64_C(1)))));
|
|
if (value == ((void *)0)) {
|
|
return (void *)0;
|
|
}
|
|
uint8_t* pointer = (uint8_t*)(value);
|
|
bool value_0 = CopyCString(name, compiler_backend_cache_BytesFromPointer(pointer, (uint64_t)(((int64_t)((uint64_t)((int64_t)(name).length) + UINT64_C(1))))));
|
|
if (!value_0) {
|
|
zir_f_36a3c20ab8e249b6_FreeOwned(value);
|
|
return (void *)0;
|
|
}
|
|
String stored = StringLiteral("");
|
|
View* descriptor = (View*)(&(stored));
|
|
uint8_t** value_1 = &(descriptor->data);
|
|
(*value_1) = pointer;
|
|
size_t* value_2 = &(descriptor->count);
|
|
(*value_2) = (size_t)((int64_t)(name).length);
|
|
String value_3 = stored;
|
|
bool value_4 = false;
|
|
void *value_5 = ZirVecGrow((void *)(ProfileNames).data, &(ProfileNames).capacity, (ProfileNames).count, sizeof(*(ProfileNames).data));
|
|
if (value_5 != NULL) {
|
|
(ProfileNames).data = (String *)value_5;
|
|
(ProfileNames).data[(ProfileNames).count++] = value_3;
|
|
value_4 = true;
|
|
}
|
|
if (!value_4) {
|
|
zir_f_36a3c20ab8e249b6_FreeOwned(value);
|
|
return (void *)0;
|
|
}
|
|
return pointer;
|
|
}
|
|
|
|
Slice
|
|
compiler_backend_cache_BytesFromPointer(uint8_t* data, uint64_t count)
|
|
{
|
|
Slice result = {0};
|
|
if (data == ((void *)0)) {
|
|
return result;
|
|
}
|
|
ByteView* descriptor = (ByteView*)(&(result));
|
|
uint8_t** value_0 = &(descriptor->data);
|
|
(*value_0) = data;
|
|
int64_t* value_1 = &(descriptor->count);
|
|
(*value_1) = (int64_t)(count);
|
|
return result;
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_Owned(String value)
|
|
{
|
|
return vec_TextDetach(vec_TextCopy(value));
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_Release(String value)
|
|
{
|
|
if ((int64_t)(value).length == 0LL) {
|
|
return;
|
|
}
|
|
View* descriptor = (View*)(&(value));
|
|
zir_f_36a3c20ab8e249b6_FreeOwned((void*)(descriptor->data));
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_SameText(String left, String right)
|
|
{
|
|
return StringEqual(left, right);
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_HasPrefix(String value, String prefix)
|
|
{
|
|
return text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_HasSuffix(String value, String suffix)
|
|
{
|
|
return text_tools_TextHasSuffix(value, suffix);
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_Contains(String value, String piece)
|
|
{
|
|
return text_tools_TextContains(value, piece);
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_TextName(String value)
|
|
{
|
|
int64_t at = (int64_t)(value).length;
|
|
while (at > 0LL && (uint8_t)ZIRAN_INDEX(value.data, value.length, ((int64_t)((uint64_t)at - UINT64_C(1)))) != 47) {
|
|
at = (int64_t)((uint64_t)at - UINT64_C(1));
|
|
}
|
|
return StringRange(value, (int64_t)at, (int64_t)(int64_t)(value).length);
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_JoinTemporary(String left, String right)
|
|
{
|
|
__type_838711075b90279a builder = {0};
|
|
__type_838711075b90279a* value_0 = &builder;
|
|
bool value_1 = false;
|
|
if ((left).length == 0) {
|
|
value_1 = true;
|
|
} else {
|
|
void *value_2 = ZirVecReserve((void *)(builder).data, &(builder).capacity, (builder).count, (int64_t)(left).length, sizeof(*(builder).data));
|
|
if (value_2 != NULL) {
|
|
(builder).data = (uint8_t *)value_2;
|
|
memcpy((builder).data + (builder).count, (left).data, (size_t)(left).length);
|
|
(builder).count += (int64_t)(left).length;
|
|
value_1 = true;
|
|
}
|
|
}
|
|
bool value_3 = !value_1;
|
|
if (!value_3) {
|
|
bool value_4 = false;
|
|
if ((right).length == 0) {
|
|
value_4 = true;
|
|
} else {
|
|
void *value_5 = ZirVecReserve((void *)(builder).data, &(builder).capacity, (builder).count, (int64_t)(right).length, sizeof(*(builder).data));
|
|
if (value_5 != NULL) {
|
|
(builder).data = (uint8_t *)value_5;
|
|
memcpy((builder).data + (builder).count, (right).data, (size_t)(right).length);
|
|
(builder).count += (int64_t)(right).length;
|
|
value_4 = true;
|
|
}
|
|
}
|
|
value_3 = !value_4;
|
|
}
|
|
if (value_3) {
|
|
free((builder).data);
|
|
(builder).data = NULL;
|
|
builder.capacity = 0;
|
|
builder.count = 0;
|
|
String value_6 = StringLiteral("");
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_6;
|
|
}
|
|
Slice value_7 = {(builder).data, (builder).count};
|
|
Slice value_8 = SliceRange(value_7, 0LL, builder.count, sizeof(*(builder).data));
|
|
String value_9 = vec_TextDetach(vec_TextCopy(StringView((const char *)(value_8).data, (size_t)(value_8).length)));
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_9;
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_JoinPath(String left, String right)
|
|
{
|
|
__type_838711075b90279a builder = {0};
|
|
__type_838711075b90279a* value_0 = &builder;
|
|
bool value_1 = false;
|
|
if ((left).length == 0) {
|
|
value_1 = true;
|
|
} else {
|
|
void *value_2 = ZirVecReserve((void *)(builder).data, &(builder).capacity, (builder).count, (int64_t)(left).length, sizeof(*(builder).data));
|
|
if (value_2 != NULL) {
|
|
(builder).data = (uint8_t *)value_2;
|
|
memcpy((builder).data + (builder).count, (left).data, (size_t)(left).length);
|
|
(builder).count += (int64_t)(left).length;
|
|
value_1 = true;
|
|
}
|
|
}
|
|
if (!value_1) {
|
|
free((builder).data);
|
|
(builder).data = NULL;
|
|
builder.capacity = 0;
|
|
builder.count = 0;
|
|
String value_3 = StringLiteral("");
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_3;
|
|
}
|
|
if ((int64_t)(left).length > 0LL && (uint8_t)ZIRAN_INDEX(left.data, left.length, ((int64_t)((uint64_t)((int64_t)(left).length) - UINT64_C(1)))) != 47) {
|
|
uint8_t value_4 = 47;
|
|
bool value_5 = false;
|
|
void *value_6 = ZirVecGrow((void *)(builder).data, &(builder).capacity, (builder).count, sizeof(*(builder).data));
|
|
if (value_6 != NULL) {
|
|
(builder).data = (uint8_t *)value_6;
|
|
(builder).data[(builder).count++] = value_4;
|
|
value_5 = true;
|
|
}
|
|
if (!value_5) {
|
|
free((builder).data);
|
|
(builder).data = NULL;
|
|
builder.capacity = 0;
|
|
builder.count = 0;
|
|
String value_7 = StringLiteral("");
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_7;
|
|
}
|
|
}
|
|
bool value_8 = false;
|
|
if ((right).length == 0) {
|
|
value_8 = true;
|
|
} else {
|
|
void *value_9 = ZirVecReserve((void *)(builder).data, &(builder).capacity, (builder).count, (int64_t)(right).length, sizeof(*(builder).data));
|
|
if (value_9 != NULL) {
|
|
(builder).data = (uint8_t *)value_9;
|
|
memcpy((builder).data + (builder).count, (right).data, (size_t)(right).length);
|
|
(builder).count += (int64_t)(right).length;
|
|
value_8 = true;
|
|
}
|
|
}
|
|
if (!value_8) {
|
|
free((builder).data);
|
|
(builder).data = NULL;
|
|
builder.capacity = 0;
|
|
builder.count = 0;
|
|
String value_10 = StringLiteral("");
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_10;
|
|
}
|
|
Slice value_11 = {(builder).data, (builder).count};
|
|
Slice value_12 = SliceRange(value_11, 0LL, builder.count, sizeof(*(builder).data));
|
|
String value_13 = vec_TextDetach(vec_TextCopy(StringView((const char *)(value_12).data, (size_t)(value_12).length)));
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_13;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_AppendOwned(__type_c53c2d7c4913dc02* values, String value)
|
|
{
|
|
String owned = compiler_backend_cache_Owned(value);
|
|
if ((int64_t)(owned).length == 0LL && (int64_t)(value).length != 0LL) {
|
|
return false;
|
|
}
|
|
String value_0 = owned;
|
|
bool value_1 = false;
|
|
void *value_2 = ZirVecGrow((void *)((*(values))).data, &((*(values))).capacity, ((*(values))).count, sizeof(*((*(values))).data));
|
|
if (value_2 != NULL) {
|
|
((*(values))).data = (String *)value_2;
|
|
((*(values))).data[((*(values))).count++] = value_0;
|
|
value_1 = true;
|
|
}
|
|
if (!value_1) {
|
|
compiler_backend_cache_Release(owned);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_ClearNames(__type_c53c2d7c4913dc02* values)
|
|
{
|
|
__type_c53c2d7c4913dc02 owned = {0};
|
|
__type_c53c2d7c4913dc02* value_0 = &owned;
|
|
__type_c53c2d7c4913dc02 value_1 = owned;
|
|
owned = (*(values));
|
|
(*(values)) = value_1;
|
|
for (int64_t it_index = 0LL; it_index < owned.count; it_index++) {
|
|
String value = ZIRAN_VEC_INDEX((owned).data, (owned).count, it_index);
|
|
compiler_backend_cache_Release(value);
|
|
}
|
|
__type_c53c2d7c4913dc02 value_2 = owned;
|
|
owned = (*(values));
|
|
(*(values)) = value_2;
|
|
free(((*(values))).data);
|
|
((*(values))).data = NULL;
|
|
(*(values)).capacity = 0;
|
|
(*(values)).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_Executable(String command)
|
|
{
|
|
String value_0 = StringLiteral("/");
|
|
bool value_1 = false;
|
|
{
|
|
String value = command;
|
|
String piece = value_0;
|
|
value_1 = text_tools_TextContains(value, piece);
|
|
}
|
|
if (value_1) {
|
|
return compiler_backend_cache_Resolved(command);
|
|
}
|
|
String search = environment_linux_EnvironmentText(StringLiteral("PATH"));
|
|
String value_3 = StringView(NULL, 0);
|
|
if ((int64_t)(search).length == 0LL) {
|
|
value_3 = StringLiteral("/bin:/usr/bin");
|
|
} else {
|
|
value_3 = search;
|
|
}
|
|
String paths = value_3;
|
|
__type_c53c2d7c4913dc02 pieces = text_tools_TextSplit(paths, StringLiteral(":"));
|
|
__type_c53c2d7c4913dc02* value_4 = &pieces;
|
|
String result = StringLiteral("");
|
|
for (int64_t it_index = 0LL; it_index < pieces.count; it_index++) {
|
|
String piece = ZIRAN_VEC_INDEX((pieces).data, (pieces).count, it_index);
|
|
String value_5 = StringView(NULL, 0);
|
|
if ((int64_t)(piece).length == 0LL) {
|
|
value_5 = StringLiteral(".");
|
|
} else {
|
|
value_5 = piece;
|
|
}
|
|
String directory = value_5;
|
|
String candidate = compiler_backend_cache_JoinPath(directory, command);
|
|
bool value_6 = (int64_t)(candidate).length > 0LL;
|
|
if (value_6) {
|
|
bool value_7 = false;
|
|
{
|
|
String path = candidate;
|
|
PathInfo info = file_tree_linux_PathStatus(path, true);
|
|
value_7 = ((PathKind)(info.kind)) == ((PathKind)(1)) && ((int32_t)((uint32_t)(info.mode) & 73u)) != 0;
|
|
}
|
|
value_6 = value_7;
|
|
}
|
|
if (value_6) {
|
|
result = compiler_backend_cache_Resolved(candidate);
|
|
compiler_backend_cache_Release(candidate);
|
|
break;
|
|
}
|
|
compiler_backend_cache_Release(candidate);
|
|
}
|
|
String value_9 = result;
|
|
free((*value_4).data);
|
|
(*value_4).data = NULL;
|
|
(*value_4).capacity = 0;
|
|
(*value_4).count = 0;
|
|
return value_9;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_Runnable(String path)
|
|
{
|
|
PathInfo info = file_tree_linux_PathStatus(path, true);
|
|
return ((PathKind)(info.kind)) == ((PathKind)(1)) && ((int32_t)((uint32_t)(info.mode) & 73u)) != 0;
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_Resolved(String path)
|
|
{
|
|
Text resolved = file_tree_linux_ResolvePath(path);
|
|
String result = vec_TextDetach(vec_TextCopy(StringView((resolved.bytes).count > 0 ? (const char *)(resolved.bytes).data : "", (size_t)(resolved.bytes).count)));
|
|
if ((int64_t)(result).length == 0LL) {
|
|
String value_0 = StringLiteral("");
|
|
free((resolved).bytes.data);
|
|
(resolved).bytes.data = NULL;
|
|
(resolved).bytes.capacity = 0;
|
|
(resolved).bytes.count = 0;
|
|
return value_0;
|
|
}
|
|
String value_1 = result;
|
|
free((resolved).bytes.data);
|
|
(resolved).bytes.data = NULL;
|
|
(resolved).bytes.capacity = 0;
|
|
(resolved).bytes.count = 0;
|
|
return value_1;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_NativeImage(String path)
|
|
{
|
|
__type_838711075b90279a bytes = {0};
|
|
__type_838711075b90279a* value_0 = &bytes;
|
|
bool value_1 = file_ReadFileInto(path, &(bytes));
|
|
if (!value_1 || bytes.count < 4LL) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool value_2 = false;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_2;
|
|
}
|
|
bool value_3 = ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 0) == 127 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 1) == 69;
|
|
bool value_4 = value_3 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 2) == 76 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 3) == 70;
|
|
bool value_5 = value_4;
|
|
if (!value_5) {
|
|
bool value_6 = ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 0) == 207 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 1) == 250;
|
|
bool value_7 = value_6 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 2) == 237 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 3) == 254;
|
|
value_5 = value_7;
|
|
}
|
|
bool value_8 = value_5;
|
|
if (!value_8) {
|
|
bool value_9 = ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 0) == 254 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 1) == 237;
|
|
bool value_10 = value_9 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 2) == 250 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 3) == 207;
|
|
value_8 = value_10;
|
|
}
|
|
bool value_11 = value_8;
|
|
if (!value_11) {
|
|
bool value_12 = ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 0) == 202 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 1) == 254;
|
|
bool value_13 = value_12 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 2) == 186 && ZIRAN_VEC_INDEX((bytes).data, (bytes).count, 3) == 190;
|
|
value_11 = value_13;
|
|
}
|
|
bool result = value_11;
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool value_14 = result;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_14;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_PairedArgument(String value)
|
|
{
|
|
String values[15] = {StringLiteral("-I"), StringLiteral("-isystem"), StringLiteral("-iquote"), StringLiteral("-idirafter"), StringLiteral("-include"), StringLiteral("-imacros"), StringLiteral("-isysroot"), StringLiteral("--sysroot"), StringLiteral("-target"), StringLiteral("--target"), StringLiteral("-x"), StringLiteral("-D"), StringLiteral("-U"), StringLiteral("-B"), StringLiteral("-Xlinker")};
|
|
for (int64_t it_index = 0LL; it_index < 15; it_index++) {
|
|
String candidate = (values)[it_index];
|
|
if (StringEqual(value, candidate)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_RequestedPipe(Slice arguments)
|
|
{
|
|
int64_t index = 1LL;
|
|
while (index < (int64_t)(arguments).length) {
|
|
if (compiler_backend_cache_PairedArgument(((String *)arguments.data)[SliceIndex(arguments, (int64_t)index)])) {
|
|
index = (int64_t)((uint64_t)index + UINT64_C(2));
|
|
continue;
|
|
}
|
|
if (StringEqual(((String *)arguments.data)[SliceIndex(arguments, (int64_t)index)], StringLiteral("-pipe"))) {
|
|
return true;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_UnsupportedEffects(void)
|
|
{
|
|
String names[6] = {StringLiteral("DEPENDENCIES_OUTPUT"), StringLiteral("SUNPRO_DEPENDENCIES"), StringLiteral("GCC_DIAGNOSTICS_LOG"), StringLiteral("GCC_COMPARE_DEBUG"), StringLiteral("GCC_EXTRA_DIAGNOSTIC_OUTPUT"), StringLiteral("EXPERIMENTAL_SARIF_SOCKET")};
|
|
for (int64_t it_index = 0LL; it_index < 6; it_index++) {
|
|
String name = (names)[it_index];
|
|
String value_0 = environment_linux_EnvironmentText(name);
|
|
int64_t value_1 = (int64_t)(value_0).length;
|
|
if (value_1 > 0LL) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_SupportedArguments(Slice arguments)
|
|
{
|
|
if (compiler_backend_cache_UnsupportedEffects()) {
|
|
return false;
|
|
}
|
|
int64_t index = 1LL;
|
|
while (index < (int64_t)(arguments).length) {
|
|
String value = ((String *)arguments.data)[SliceIndex(arguments, (int64_t)index)];
|
|
String value_0 = value;
|
|
String value_1 = StringLiteral("__DATE__");
|
|
bool value_2 = false;
|
|
{
|
|
String value = value_0;
|
|
String piece = value_1;
|
|
value_2 = text_tools_TextContains(value, piece);
|
|
}
|
|
bool value_4 = value_2;
|
|
if (!value_4) {
|
|
String value_5 = value;
|
|
String value_6 = StringLiteral("__TIME__");
|
|
bool value_7 = false;
|
|
{
|
|
String value = value_5;
|
|
String piece = value_6;
|
|
value_7 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_4 = value_7;
|
|
}
|
|
bool value_9 = value_4;
|
|
if (!value_9) {
|
|
String value_10 = value;
|
|
String value_11 = StringLiteral("__TIMESTAMP__");
|
|
bool value_12 = false;
|
|
{
|
|
String value = value_10;
|
|
String piece = value_11;
|
|
value_12 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_9 = value_12;
|
|
}
|
|
bool value_14 = value_9;
|
|
if (!value_14) {
|
|
String value_15 = value;
|
|
String value_16 = StringLiteral("__has_include");
|
|
bool value_17 = false;
|
|
{
|
|
String value = value_15;
|
|
String piece = value_16;
|
|
value_17 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_14 = value_17;
|
|
}
|
|
bool value_19 = value_14 || StringEqual(value, StringLiteral("-march=native")) || StringEqual(value, StringLiteral("-mcpu=native"));
|
|
if (value_19 || StringEqual(value, StringLiteral("-mtune=native"))) {
|
|
return false;
|
|
}
|
|
if (compiler_backend_cache_PairedArgument(value)) {
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
if (index >= (int64_t)(arguments).length || (StringEqual(value, StringLiteral("-x")) && !StringEqual(((String *)arguments.data)[SliceIndex(arguments, (int64_t)index)], StringLiteral("c")))) {
|
|
return false;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
bool value_20 = compiler_backend_cache_SupportedOption(value);
|
|
if (!value_20) {
|
|
return false;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_SupportedOption(String value)
|
|
{
|
|
String value_0 = value;
|
|
String value_1 = StringLiteral("-D");
|
|
bool value_2 = false;
|
|
{
|
|
String value = value_0;
|
|
String prefix = value_1;
|
|
value_2 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
bool value_4 = value_2;
|
|
if (!value_4) {
|
|
String value_5 = value;
|
|
String value_6 = StringLiteral("-U");
|
|
bool value_7 = false;
|
|
{
|
|
String value = value_5;
|
|
String prefix = value_6;
|
|
value_7 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_4 = value_7;
|
|
}
|
|
bool value_9 = value_4;
|
|
if (!value_9) {
|
|
String value_10 = value;
|
|
String value_11 = StringLiteral("-I");
|
|
bool value_12 = false;
|
|
{
|
|
String value = value_10;
|
|
String prefix = value_11;
|
|
value_12 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_9 = value_12;
|
|
}
|
|
bool value_14 = value_9;
|
|
if (!value_14) {
|
|
String value_15 = value;
|
|
String value_16 = StringLiteral("-std=");
|
|
bool value_17 = false;
|
|
{
|
|
String value = value_15;
|
|
String prefix = value_16;
|
|
value_17 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_14 = value_17;
|
|
}
|
|
bool value_19 = value_14;
|
|
if (!value_19) {
|
|
String value_20 = value;
|
|
String value_21 = StringLiteral("--sysroot=");
|
|
bool value_22 = false;
|
|
{
|
|
String value = value_20;
|
|
String prefix = value_21;
|
|
value_22 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_19 = value_22;
|
|
}
|
|
bool value_24 = value_19;
|
|
if (!value_24) {
|
|
String value_25 = value;
|
|
String value_26 = StringLiteral("--target=");
|
|
bool value_27 = false;
|
|
{
|
|
String value = value_25;
|
|
String prefix = value_26;
|
|
value_27 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_24 = value_27;
|
|
}
|
|
if (value_24) {
|
|
return true;
|
|
}
|
|
String value_29 = value;
|
|
String value_30 = StringLiteral("-Wl,");
|
|
bool value_31 = false;
|
|
{
|
|
String value = value_29;
|
|
String prefix = value_30;
|
|
value_31 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
bool value_33 = value_31;
|
|
if (!value_33) {
|
|
String value_34 = value;
|
|
String value_35 = StringLiteral("-fuse-ld=");
|
|
bool value_36 = false;
|
|
{
|
|
String value = value_34;
|
|
String prefix = value_35;
|
|
value_36 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_33 = (value_36 && (int64_t)(value).length > 9LL);
|
|
}
|
|
bool value_38 = value_33;
|
|
if (!value_38) {
|
|
String value_39 = value;
|
|
String value_40 = StringLiteral("-B");
|
|
bool value_41 = false;
|
|
{
|
|
String value = value_39;
|
|
String prefix = value_40;
|
|
value_41 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_38 = (value_41 && (int64_t)(value).length > 2LL);
|
|
}
|
|
if (value_38) {
|
|
return true;
|
|
}
|
|
String value_43 = value;
|
|
String value_44 = StringLiteral("-W");
|
|
bool value_45 = false;
|
|
{
|
|
String value = value_43;
|
|
String prefix = value_44;
|
|
value_45 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
bool value_47 = value_45;
|
|
if (value_47) {
|
|
String value_48 = value;
|
|
String value_49 = StringLiteral("-Wa,");
|
|
bool value_50 = false;
|
|
{
|
|
String value = value_48;
|
|
String prefix = value_49;
|
|
value_50 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_47 = !value_50;
|
|
}
|
|
bool value_52 = value_47;
|
|
if (value_52) {
|
|
String value_53 = value;
|
|
String value_54 = StringLiteral("-Wp,");
|
|
bool value_55 = false;
|
|
{
|
|
String value = value_53;
|
|
String prefix = value_54;
|
|
value_55 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_52 = !value_55;
|
|
}
|
|
bool value_57 = value_52;
|
|
if (value_57) {
|
|
String value_58 = value;
|
|
String value_59 = StringLiteral("-Wl,");
|
|
bool value_60 = false;
|
|
{
|
|
String value = value_58;
|
|
String prefix = value_59;
|
|
value_60 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_57 = !value_60;
|
|
}
|
|
if (value_57) {
|
|
return true;
|
|
}
|
|
String value_62 = value;
|
|
String value_63 = StringLiteral("-g");
|
|
bool value_64 = false;
|
|
{
|
|
String value = value_62;
|
|
String prefix = value_63;
|
|
value_64 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
bool value_66 = value_64;
|
|
if (value_66) {
|
|
String value_67 = value;
|
|
String value_68 = StringLiteral("-gsplit");
|
|
bool value_69 = false;
|
|
{
|
|
String value = value_67;
|
|
String prefix = value_68;
|
|
value_69 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_66 = !value_69;
|
|
}
|
|
if (value_66) {
|
|
return true;
|
|
}
|
|
String optimizations[8] = {StringLiteral("-O0"), StringLiteral("-O1"), StringLiteral("-O2"), StringLiteral("-O3"), StringLiteral("-Os"), StringLiteral("-Oz"), StringLiteral("-Og"), StringLiteral("-Ofast")};
|
|
for (int64_t it_index = 0LL; it_index < 8; it_index++) {
|
|
String known = (optimizations)[it_index];
|
|
if (StringEqual(value, known)) {
|
|
return true;
|
|
}
|
|
}
|
|
String value_71 = value;
|
|
String value_72 = StringLiteral("-m");
|
|
bool value_73 = false;
|
|
{
|
|
String value = value_71;
|
|
String prefix = value_72;
|
|
value_73 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
if (value_73 && !StringEqual(value, StringLiteral("-mllvm"))) {
|
|
return true;
|
|
}
|
|
String plain[29] = {StringLiteral("-pthread"), StringLiteral("-pipe"), StringLiteral("-pedantic"), StringLiteral("-pedantic-errors"), StringLiteral("-ansi"), StringLiteral("-nostdinc"), StringLiteral("-nostdlib"), StringLiteral("-static"), StringLiteral("-shared"), StringLiteral("-s"), StringLiteral("-fPIC"), StringLiteral("-fpic"), StringLiteral("-fPIE"), StringLiteral("-fpie"), StringLiteral("-fno-plt"), StringLiteral("-fomit-frame-pointer"), StringLiteral("-fno-omit-frame-pointer"), StringLiteral("-ffast-math"), StringLiteral("-fno-fast-math"), StringLiteral("-fstrict-aliasing"), StringLiteral("-fno-strict-aliasing"), StringLiteral("-fwrapv"), StringLiteral("-fno-wrapv"), StringLiteral("-fcommon"), StringLiteral("-fno-common"), StringLiteral("-fsigned-char"), StringLiteral("-funsigned-char"), StringLiteral("-fexceptions"), StringLiteral("-fno-exceptions")};
|
|
for (int64_t it_index = 0LL; it_index < 29; it_index++) {
|
|
String known = (plain)[it_index];
|
|
if (StringEqual(value, known)) {
|
|
return true;
|
|
}
|
|
}
|
|
String value_75 = value;
|
|
String value_76 = StringLiteral("-flto");
|
|
bool value_77 = false;
|
|
{
|
|
String value = value_75;
|
|
String prefix = value_76;
|
|
value_77 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
bool value_79 = value_77;
|
|
if (!value_79) {
|
|
String value_80 = value;
|
|
String value_81 = StringLiteral("-fvisibility=");
|
|
bool value_82 = false;
|
|
{
|
|
String value = value_80;
|
|
String prefix = value_81;
|
|
value_82 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_79 = value_82;
|
|
}
|
|
return value_79;
|
|
}
|
|
|
|
int64_t
|
|
compiler_backend_cache_FileFind(BuildCache* cache, String path, bool directory)
|
|
{
|
|
if (directory) {
|
|
{
|
|
int64_t range_first_1 = 0LL;
|
|
int64_t range_last_1 = (int64_t)((uint64_t)(cache->candidates.count) - UINT64_C(1));
|
|
int64_t index = range_first_1;
|
|
if (index <= range_last_1) for (;;) {
|
|
if (StringEqual((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, index)).path, path)) {
|
|
return index;
|
|
}
|
|
if (index == range_last_1) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
} else {
|
|
{
|
|
int64_t range_first_8 = 0LL;
|
|
int64_t range_last_8 = (int64_t)((uint64_t)(cache->files.count) - UINT64_C(1));
|
|
int64_t index = range_first_8;
|
|
if (index <= range_last_8) for (;;) {
|
|
if (StringEqual((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, index)).path, path)) {
|
|
return index;
|
|
}
|
|
if (index == range_last_8) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
int64_t
|
|
compiler_backend_cache_FileAdd(BuildCache* cache, String path, bool directory)
|
|
{
|
|
int64_t value_0 = (int64_t)((uint64_t)(cache->files.count) + (uint64_t)(cache->candidates.count));
|
|
if (value_0 >= 262144LL || (int64_t)(path).length >= 4096LL) {
|
|
return -1LL;
|
|
}
|
|
Fingerprint item = {0};
|
|
bool* value_1 = &(item.directory);
|
|
(*value_1) = directory;
|
|
if (directory) {
|
|
Fingerprint value_2 = item;
|
|
for (size_t value_3 = 0; value_3 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_3) {
|
|
}
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
Fingerprint value_4 = value_2;
|
|
bool value_5 = false;
|
|
void *value_6 = ZirVecGrow((void *)(cache->candidates).data, &(cache->candidates).capacity, (cache->candidates).count, sizeof(*(cache->candidates).data));
|
|
if (value_6 != NULL) {
|
|
(cache->candidates).data = (Fingerprint *)value_6;
|
|
(cache->candidates).data[(cache->candidates).count++] = value_4;
|
|
value_5 = true;
|
|
}
|
|
if (!value_5) {
|
|
int64_t value_7 = -1LL;
|
|
for (size_t value_8 = 0; value_8 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_8) {
|
|
}
|
|
free((item).probes.data);
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
return value_7;
|
|
}
|
|
int64_t index = (int64_t)((uint64_t)(cache->candidates.count) - UINT64_C(1));
|
|
String* value_9 = &((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, index)).path);
|
|
String value_10 = compiler_backend_cache_Owned(path);
|
|
(*value_9) = value_10;
|
|
int64_t value_11 = (int64_t)((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, index)).path).length;
|
|
if (value_11 == 0LL && (int64_t)(path).length != 0LL) {
|
|
int64_t value_12 = -1LL;
|
|
for (size_t value_13 = 0; value_13 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_13) {
|
|
}
|
|
free((item).probes.data);
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
return value_12;
|
|
}
|
|
int64_t value_14 = index;
|
|
for (size_t value_15 = 0; value_15 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_15) {
|
|
}
|
|
free((item).probes.data);
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
return value_14;
|
|
}
|
|
Fingerprint value_16 = item;
|
|
for (size_t value_17 = 0; value_17 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_17) {
|
|
}
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
Fingerprint value_18 = value_16;
|
|
bool value_19 = false;
|
|
void *value_20 = ZirVecGrow((void *)(cache->files).data, &(cache->files).capacity, (cache->files).count, sizeof(*(cache->files).data));
|
|
if (value_20 != NULL) {
|
|
(cache->files).data = (Fingerprint *)value_20;
|
|
(cache->files).data[(cache->files).count++] = value_18;
|
|
value_19 = true;
|
|
}
|
|
if (!value_19) {
|
|
int64_t value_21 = -1LL;
|
|
for (size_t value_22 = 0; value_22 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_22) {
|
|
}
|
|
free((item).probes.data);
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
return value_21;
|
|
}
|
|
int64_t index = (int64_t)((uint64_t)(cache->files.count) - UINT64_C(1));
|
|
String* value_23 = &((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, index)).path);
|
|
String value_24 = compiler_backend_cache_Owned(path);
|
|
(*value_23) = value_24;
|
|
int64_t value_25 = (int64_t)((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, index)).path).length;
|
|
if (value_25 == 0LL && (int64_t)(path).length != 0LL) {
|
|
int64_t value_26 = -1LL;
|
|
for (size_t value_27 = 0; value_27 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_27) {
|
|
}
|
|
free((item).probes.data);
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
return value_26;
|
|
}
|
|
int64_t value_28 = index;
|
|
for (size_t value_29 = 0; value_29 < sizeof(((item).digest).bytes) / sizeof((((item).digest).bytes)[0]); ++value_29) {
|
|
}
|
|
free((item).probes.data);
|
|
(item).probes.data = NULL;
|
|
(item).probes.capacity = 0;
|
|
(item).probes.count = 0;
|
|
return value_28;
|
|
}
|
|
|
|
int64_t
|
|
compiler_backend_cache_ProbeLiteral(String text, int64_t start, String* name)
|
|
{
|
|
int64_t at = start;
|
|
String value_0 = text;
|
|
int64_t value_1 = (int64_t)((uint64_t)at + UINT64_C(5));
|
|
int64_t value_2 = (int64_t)(text).length;
|
|
int64_t value_3 = 0;
|
|
{
|
|
int64_t left = value_1;
|
|
int64_t right = value_2;
|
|
int64_t value_5 = 0;
|
|
if (left < right) {
|
|
value_5 = left;
|
|
} else {
|
|
value_5 = right;
|
|
}
|
|
value_3 = value_5;
|
|
}
|
|
String value_6 = StringRange(value_0, (int64_t)at, (int64_t)value_3);
|
|
String value_7 = StringLiteral("_next");
|
|
bool value_8 = false;
|
|
{
|
|
String value = value_6;
|
|
String prefix = value_7;
|
|
value_8 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
if (value_8) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(5));
|
|
}
|
|
while (at < (int64_t)(text).length && text_tools_TextIsSpace((uint8_t)ZIRAN_INDEX(text.data, text.length, at))) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (at >= (int64_t)(text).length || (uint8_t)ZIRAN_INDEX(text.data, text.length, at) != 40) {
|
|
return -1LL;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
while (at < (int64_t)(text).length && text_tools_TextIsSpace((uint8_t)ZIRAN_INDEX(text.data, text.length, at))) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (at >= (int64_t)(text).length) {
|
|
return -1LL;
|
|
}
|
|
int64_t value_10 = 0;
|
|
if ((uint8_t)ZIRAN_INDEX(text.data, text.length, at) == 34) {
|
|
value_10 = 34LL;
|
|
} else {
|
|
int64_t value_11 = 0;
|
|
if ((uint8_t)ZIRAN_INDEX(text.data, text.length, at) == 60) {
|
|
value_11 = 62LL;
|
|
} else {
|
|
value_11 = 0LL;
|
|
}
|
|
value_10 = value_11;
|
|
}
|
|
int64_t end = value_10;
|
|
if (end == 0LL) {
|
|
return -1LL;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
int64_t first = at;
|
|
while (true) {
|
|
bool value_12 = at < (int64_t)(text).length;
|
|
if (value_12) {
|
|
int64_t value_13 = (int64_t)((uint8_t)ZIRAN_INDEX(text.data, text.length, at));
|
|
value_12 = (value_13 != end);
|
|
}
|
|
if (!value_12) { break; }
|
|
if ((uint8_t)ZIRAN_INDEX(text.data, text.length, at) == 47 || (uint8_t)ZIRAN_INDEX(text.data, text.length, at) == 10) {
|
|
return -1LL;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (at >= (int64_t)(text).length || at == first || (int64_t)((uint64_t)at - (uint64_t)first) >= 4096LL) {
|
|
return -1LL;
|
|
}
|
|
String literal = compiler_backend_cache_Owned(StringRange(text, (int64_t)first, (int64_t)at));
|
|
if ((int64_t)(literal).length == 0LL) {
|
|
return -1LL;
|
|
}
|
|
String* value_14 = &((*(name)));
|
|
(*value_14) = literal;
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
while (at < (int64_t)(text).length && text_tools_TextIsSpace((uint8_t)ZIRAN_INDEX(text.data, text.length, at))) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (at < (int64_t)(text).length && (uint8_t)ZIRAN_INDEX(text.data, text.length, at) == 41) {
|
|
return (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return -1LL;
|
|
}
|
|
|
|
int64_t
|
|
compiler_backend_cache_Minimum(int64_t left, int64_t right)
|
|
{
|
|
int64_t value_0 = 0;
|
|
if (left < right) {
|
|
value_0 = left;
|
|
} else {
|
|
value_0 = right;
|
|
}
|
|
return value_0;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_UnsafeText(String text)
|
|
{
|
|
String tokens[6] = {StringLiteral("__DATE__"), StringLiteral("__TIME__"), StringLiteral("__TIMESTAMP__"), StringLiteral(".incbin"), StringLiteral(".include"), StringLiteral("../")};
|
|
for (int64_t it_index = 0LL; it_index < 6; it_index++) {
|
|
String token = (tokens)[it_index];
|
|
bool value_0 = false;
|
|
{
|
|
String value = text;
|
|
String piece = token;
|
|
value_0 = text_tools_TextContains(value, piece);
|
|
}
|
|
if (value_0) {
|
|
return true;
|
|
}
|
|
}
|
|
int64_t at = text_tools_TextFind(text, StringLiteral("__has_include"), 0LL);
|
|
while (at >= 0LL) {
|
|
String name = StringLiteral("");
|
|
at = compiler_backend_cache_ProbeLiteral(text, (int64_t)((uint64_t)at + UINT64_C(13)), &(name));
|
|
if (at < 0LL) {
|
|
compiler_backend_cache_Release(name);
|
|
return true;
|
|
}
|
|
compiler_backend_cache_Release(name);
|
|
at = text_tools_TextFind(text, StringLiteral("__has_include"), at);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_ProbeNames(String text, __type_c53c2d7c4913dc02* names)
|
|
{
|
|
int64_t at = text_tools_TextFind(text, StringLiteral("__has_include"), 0LL);
|
|
while (at >= 0LL) {
|
|
String name = StringLiteral("");
|
|
at = compiler_backend_cache_ProbeLiteral(text, (int64_t)((uint64_t)at + UINT64_C(13)), &(name));
|
|
bool value_0 = at < 0LL;
|
|
if (!value_0) {
|
|
bool value_1 = compiler_backend_cache_AppendOwned(names, name);
|
|
value_0 = !value_1;
|
|
}
|
|
if (value_0) {
|
|
compiler_backend_cache_Release(name);
|
|
return false;
|
|
}
|
|
compiler_backend_cache_Release(name);
|
|
at = text_tools_TextFind(text, StringLiteral("__has_include"), at);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int64_t
|
|
compiler_backend_cache_FileDigest(BuildCache* cache, String path)
|
|
{
|
|
PathInfo before = file_tree_linux_PathStatus(path, true);
|
|
if (((PathKind)(before.kind)) != ((PathKind)(1))) {
|
|
return -1LL;
|
|
}
|
|
int64_t found = compiler_backend_cache_FileFind(cache, path, false);
|
|
bool value_0 = found >= 0LL;
|
|
if (value_0 && file_tree_linux_SameFileSnapshot((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).info, before)) {
|
|
return found;
|
|
}
|
|
__type_838711075b90279a bytes = {0};
|
|
__type_838711075b90279a* value_1 = &bytes;
|
|
bool value_2 = file_ReadFileInto(path, &(bytes));
|
|
if (!value_2) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
int64_t value_3 = -1LL;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return value_3;
|
|
}
|
|
Slice value_4 = {(bytes).data, (bytes).count};
|
|
Slice value_5 = SliceRange(value_4, 0LL, bytes.count, sizeof(*(bytes).data));
|
|
String text = StringView((const char *)(value_5).data, (size_t)(value_5).length);
|
|
HashState hash = compiler_backend_cache_HashNew();
|
|
compiler_backend_cache_HashBytes(&(hash), text);
|
|
bool unsafe = false;
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(text).length; it_index++) {
|
|
uint8_t byte = (uint8_t)text.data[it_index];
|
|
if (byte == 0) {
|
|
unsafe = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!unsafe) {
|
|
unsafe = compiler_backend_cache_UnsafeText(text);
|
|
}
|
|
__type_c53c2d7c4913dc02 probes = {0};
|
|
__type_c53c2d7c4913dc02* value_6 = &probes;
|
|
String value_7 = StringLiteral("__has_include");
|
|
bool value_8 = false;
|
|
{
|
|
String value = text;
|
|
String piece = value_7;
|
|
value_8 = text_tools_TextContains(value, piece);
|
|
}
|
|
bool value_10 = value_8 && !unsafe;
|
|
bool value_11 = value_10;
|
|
if (value_11) {
|
|
bool value_12 = compiler_backend_cache_ProbeNames(text, &(probes));
|
|
value_11 = !value_12;
|
|
}
|
|
if (value_11) {
|
|
compiler_backend_cache_ClearNames(&(probes));
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
int64_t value_13 = -1LL;
|
|
free((*value_6).data);
|
|
(*value_6).data = NULL;
|
|
(*value_6).capacity = 0;
|
|
(*value_6).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return value_13;
|
|
}
|
|
PathInfo after = file_tree_linux_PathStatus(path, true);
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool value_14 = file_tree_linux_SameFileSnapshot(before, after);
|
|
if (!value_14) {
|
|
compiler_backend_cache_ClearNames(&(probes));
|
|
int64_t value_15 = -1LL;
|
|
free((*value_6).data);
|
|
(*value_6).data = NULL;
|
|
(*value_6).capacity = 0;
|
|
(*value_6).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return value_15;
|
|
}
|
|
if (found < 0LL) {
|
|
found = compiler_backend_cache_FileAdd(cache, path, false);
|
|
if (found < 0LL) {
|
|
compiler_backend_cache_ClearNames(&(probes));
|
|
int64_t value_16 = -1LL;
|
|
free((*value_6).data);
|
|
(*value_6).data = NULL;
|
|
(*value_6).capacity = 0;
|
|
(*value_6).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return value_16;
|
|
}
|
|
} else {
|
|
compiler_backend_cache_ClearNames(&((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).probes));
|
|
}
|
|
__type_c53c2d7c4913dc02 value_17 = probes;
|
|
probes = (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).probes;
|
|
(ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).probes = value_17;
|
|
PathInfo* value_18 = &((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).info);
|
|
(*value_18) = after;
|
|
bool* value_19 = &((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).unsafe);
|
|
(*value_19) = unsafe;
|
|
String* value_20 = &((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).parent);
|
|
(*value_20) = StringLiteral("");
|
|
bool* value_21 = &((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).recent);
|
|
(*value_21) = false;
|
|
compiler_backend_cache_HashFinish(&(hash), &((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, found)).digest));
|
|
int64_t value_22 = found;
|
|
free((*value_6).data);
|
|
(*value_6).data = NULL;
|
|
(*value_6).capacity = 0;
|
|
(*value_6).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return value_22;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_OlderThanBuild(BuildCache* cache, PathInfo info, bool changed)
|
|
{
|
|
int64_t value_0 = 0;
|
|
if (changed) {
|
|
value_0 = info.changed;
|
|
} else {
|
|
value_0 = info.modified;
|
|
}
|
|
int64_t seconds = value_0;
|
|
uint32_t value_1 = 0;
|
|
if (changed) {
|
|
value_1 = info.changed_nanoseconds;
|
|
} else {
|
|
value_1 = info.modified_nanoseconds;
|
|
}
|
|
uint32_t nanoseconds = value_1;
|
|
int64_t value_2 = cache->started_seconds;
|
|
if (seconds != value_2) {
|
|
int64_t value_3 = cache->started_seconds;
|
|
return seconds < value_3;
|
|
}
|
|
int64_t value_4 = (int64_t)(nanoseconds);
|
|
int64_t value_5 = cache->started_nanoseconds;
|
|
return value_4 < value_5;
|
|
}
|
|
|
|
int64_t
|
|
compiler_backend_cache_SpellingDigest(BuildCache* cache, String spelling, String root)
|
|
{
|
|
String value_0 = StringLiteral("\n");
|
|
bool value_1 = false;
|
|
{
|
|
String value = spelling;
|
|
String piece = value_0;
|
|
value_1 = text_tools_TextContains(value, piece);
|
|
}
|
|
bool value_3 = value_1;
|
|
if (!value_3) {
|
|
String value_4 = StringLiteral("\n");
|
|
bool value_5 = false;
|
|
{
|
|
String value = root;
|
|
String piece = value_4;
|
|
value_5 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_3 = value_5;
|
|
}
|
|
if (value_3) {
|
|
return -1LL;
|
|
}
|
|
String value_7 = compiler_backend_cache_JoinTemporary(root, StringLiteral("\n"));
|
|
String key = compiler_backend_cache_JoinTemporary(value_7, spelling);
|
|
if ((int64_t)(key).length == 0LL) {
|
|
return -1LL;
|
|
}
|
|
int64_t found = compiler_backend_cache_FileFind(cache, key, true);
|
|
if (found >= 0LL) {
|
|
compiler_backend_cache_Release(key);
|
|
if ((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, found)).unsafe) {
|
|
return -1LL;
|
|
}
|
|
return found;
|
|
}
|
|
found = compiler_backend_cache_FileAdd(cache, key, true);
|
|
compiler_backend_cache_Release(key);
|
|
if (found < 0LL) {
|
|
return -1LL;
|
|
}
|
|
bool* value_8 = &((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, found)).unsafe);
|
|
(*value_8) = true;
|
|
HashState hash = compiler_backend_cache_HashNew();
|
|
int64_t roots = cache->roots.count;
|
|
bool use_root = (int64_t)(root).length > 0LL;
|
|
if (use_root) {
|
|
roots = 1LL;
|
|
}
|
|
{
|
|
int64_t range_first_27 = 0LL;
|
|
int64_t range_last_27 = (int64_t)((uint64_t)roots - UINT64_C(1));
|
|
int64_t root_index = range_first_27;
|
|
if (root_index <= range_last_27) for (;;) {
|
|
String value_9 = StringView(NULL, 0);
|
|
if (use_root) {
|
|
value_9 = root;
|
|
} else {
|
|
value_9 = ZIRAN_VEC_INDEX((cache->roots).data, (cache->roots).count, root_index);
|
|
}
|
|
String directory = value_9;
|
|
int64_t at = 0LL;
|
|
while (at < (int64_t)(spelling).length && (uint8_t)ZIRAN_INDEX(spelling.data, spelling.length, at) == 47) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
while (at < (int64_t)(spelling).length && at > -1LL) {
|
|
String candidate = compiler_backend_cache_JoinPath(directory, StringRange(spelling, (int64_t)at, (int64_t)(int64_t)(spelling).length));
|
|
if ((int64_t)(candidate).length == 0LL) {
|
|
return -1LL;
|
|
}
|
|
compiler_backend_cache_HashText(&(hash), candidate);
|
|
PathInfo info = file_tree_linux_PathStatus(candidate, true);
|
|
compiler_backend_cache_Release(candidate);
|
|
if (info.identity_valid) {
|
|
int64_t value_10 = 0;
|
|
if (((PathKind)(info.kind)) == ((PathKind)(1))) {
|
|
value_10 = 32768LL;
|
|
} else {
|
|
int64_t value_11 = 0;
|
|
if (((PathKind)(info.kind)) == ((PathKind)(2))) {
|
|
value_11 = 16384LL;
|
|
} else {
|
|
value_11 = 0LL;
|
|
}
|
|
value_10 = value_11;
|
|
}
|
|
int64_t kind = value_10;
|
|
compiler_backend_cache_HashInteger(&(hash), (uint64_t)(kind));
|
|
BuildCache* value_12 = cache;
|
|
PathInfo value_13 = info;
|
|
bool value_14 = false;
|
|
{
|
|
BuildCache* cache = value_12;
|
|
PathInfo info = value_13;
|
|
bool changed = true;
|
|
int64_t value_16 = 0;
|
|
if (changed) {
|
|
value_16 = info.changed;
|
|
} else {
|
|
value_16 = info.modified;
|
|
}
|
|
int64_t seconds = value_16;
|
|
uint32_t value_17 = 0;
|
|
if (changed) {
|
|
value_17 = info.changed_nanoseconds;
|
|
} else {
|
|
value_17 = info.modified_nanoseconds;
|
|
}
|
|
uint32_t nanoseconds = value_17;
|
|
int64_t value_18 = cache->started_seconds;
|
|
if (seconds != value_18) {
|
|
int64_t value_19 = cache->started_seconds;
|
|
value_14 = seconds < value_19;
|
|
goto value_15;
|
|
}
|
|
int64_t value_20 = (int64_t)(nanoseconds);
|
|
int64_t value_21 = cache->started_nanoseconds;
|
|
value_14 = value_20 < value_21;
|
|
value_15: ;
|
|
}
|
|
if (!value_14) {
|
|
bool* value_22 = &((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, found)).recent);
|
|
(*value_22) = true;
|
|
}
|
|
} else {
|
|
compiler_backend_cache_HashInteger(&(hash), 0ULL);
|
|
}
|
|
int64_t slash = text_tools_TextFind(spelling, StringLiteral("/"), at);
|
|
if (slash < 0LL) {
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)slash + UINT64_C(1));
|
|
while (at < (int64_t)(spelling).length && (uint8_t)ZIRAN_INDEX(spelling.data, spelling.length, at) == 47) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
if (at >= (int64_t)(spelling).length) {
|
|
break;
|
|
}
|
|
}
|
|
if (root_index == range_last_27) {
|
|
break;
|
|
}
|
|
root_index = (int64_t)((uint64_t)root_index + UINT64_C(1));
|
|
}
|
|
}
|
|
compiler_backend_cache_HashFinish(&(hash), &((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, found)).digest));
|
|
bool* value_23 = &((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, found)).unsafe);
|
|
(*value_23) = false;
|
|
return found;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_EnvironmentEntries(Slice bytes, __type_c53c2d7c4913dc02* entries)
|
|
{
|
|
int64_t start = 0LL;
|
|
{
|
|
int64_t range_first_1 = 0LL;
|
|
int64_t range_last_1 = (int64_t)((uint64_t)((int64_t)(bytes).length) - UINT64_C(1));
|
|
int64_t index = range_first_1;
|
|
if (index <= range_last_1) for (;;) {
|
|
if (((uint8_t *)bytes.data)[SliceIndex(bytes, (int64_t)index)] != 0) {
|
|
if (index == range_last_1) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
bool value_0 = index > start;
|
|
if (value_0) {
|
|
Slice value_1 = bytes;
|
|
Slice value_2 = SliceRange(value_1, (int64_t)start, (int64_t)index, sizeof(uint8_t));
|
|
String value_3 = StringView((const char *)(value_2).data, (size_t)(value_2).length);
|
|
bool value_4 = false;
|
|
void *value_5 = ZirVecGrow((void *)((*(entries))).data, &((*(entries))).capacity, ((*(entries))).count, sizeof(*((*(entries))).data));
|
|
if (value_5 != NULL) {
|
|
((*(entries))).data = (String *)value_5;
|
|
((*(entries))).data[((*(entries))).count++] = value_3;
|
|
value_4 = true;
|
|
}
|
|
value_0 = !value_4;
|
|
}
|
|
if (value_0) {
|
|
return false;
|
|
}
|
|
start = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
if (index == range_last_1) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
bool value_6 = start == (int64_t)(bytes).length;
|
|
bool value_7 = value_6;
|
|
if (!value_7) {
|
|
bool value_8 = start < (int64_t)(bytes).length;
|
|
bool value_9 = value_8;
|
|
if (value_9) {
|
|
Slice value_10 = bytes;
|
|
Slice value_11 = SliceRange(value_10, (int64_t)start, (int64_t)(int64_t)(bytes).length, sizeof(uint8_t));
|
|
String value_12 = StringView((const char *)(value_11).data, (size_t)(value_11).length);
|
|
bool value_13 = false;
|
|
void *value_14 = ZirVecGrow((void *)((*(entries))).data, &((*(entries))).capacity, ((*(entries))).count, sizeof(*((*(entries))).data));
|
|
if (value_14 != NULL) {
|
|
((*(entries))).data = (String *)value_14;
|
|
((*(entries))).data[((*(entries))).count++] = value_12;
|
|
value_13 = true;
|
|
}
|
|
value_9 = value_13;
|
|
}
|
|
value_7 = value_9;
|
|
}
|
|
return value_7;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_CompilerEnvironment(String entry)
|
|
{
|
|
String names[13] = {StringLiteral("PATH"), StringLiteral("CPATH"), StringLiteral("C_INCLUDE_PATH"), StringLiteral("CPLUS_INCLUDE_PATH"), StringLiteral("OBJC_INCLUDE_PATH"), StringLiteral("OBJCPLUS_INCLUDE_PATH"), StringLiteral("COMPILER_PATH"), StringLiteral("LIBRARY_PATH"), StringLiteral("SOURCE_DATE_EPOCH"), StringLiteral("SDKROOT"), StringLiteral("DEVELOPER_DIR"), StringLiteral("ZERO_AR_DATE"), StringLiteral("LANG")};
|
|
int64_t equals = text_tools_TextFind(entry, StringLiteral("="), 0LL);
|
|
String value_0 = StringView(NULL, 0);
|
|
if (equals >= 0LL) {
|
|
value_0 = StringRange(entry, (int64_t)0LL, (int64_t)equals);
|
|
} else {
|
|
value_0 = entry;
|
|
}
|
|
String name = value_0;
|
|
for (int64_t it_index = 0LL; it_index < 13; it_index++) {
|
|
String known = (names)[it_index];
|
|
if (StringEqual(name, known)) {
|
|
return true;
|
|
}
|
|
}
|
|
String prefixes[10] = {StringLiteral("LC_"), StringLiteral("GCC_"), StringLiteral("COLLECT_"), StringLiteral("CC_"), StringLiteral("CCC_"), StringLiteral("CLANG_"), StringLiteral("LLVM_"), StringLiteral("RC_"), StringLiteral("LD_"), StringLiteral("DYLD_")};
|
|
for (int64_t it_index = 0LL; it_index < 10; it_index++) {
|
|
String prefix = (prefixes)[it_index];
|
|
String value_1 = prefix;
|
|
bool value_2 = false;
|
|
{
|
|
String value = entry;
|
|
String prefix = value_1;
|
|
value_2 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
if (value_2) {
|
|
return true;
|
|
}
|
|
}
|
|
String value_4 = StringLiteral("_DEPLOYMENT_TARGET");
|
|
bool value_5 = false;
|
|
{
|
|
String value = name;
|
|
String suffix = value_4;
|
|
value_5 = text_tools_TextHasSuffix(value, suffix);
|
|
}
|
|
return value_5;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_HashEnvironment(HashState* hash)
|
|
{
|
|
__type_838711075b90279a bytes = {0};
|
|
__type_838711075b90279a* value_0 = &bytes;
|
|
bool value_1 = file_ReadFileInto(StringLiteral("/proc/self/environ"), &(bytes));
|
|
if (!value_1) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool value_2 = false;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_2;
|
|
}
|
|
__type_c53c2d7c4913dc02 entries = {0};
|
|
__type_c53c2d7c4913dc02* value_3 = &entries;
|
|
Slice value_4 = {(bytes).data, (bytes).count};
|
|
bool ok = compiler_backend_cache_EnvironmentEntries(SliceRange(value_4, 0LL, bytes.count, sizeof(*(bytes).data)), &(entries));
|
|
if (ok) {
|
|
Slice value_5 = {(entries).data, (entries).count};
|
|
sort_SortText(SliceRange(value_5, 0LL, entries.count, sizeof(*(entries).data)));
|
|
{
|
|
Slice value_6 = {(entries).data, (entries).count};
|
|
Slice value_7 = SliceRange(value_6, 0LL, entries.count, sizeof(*(entries).data));
|
|
Slice loop_view_9 = value_7;
|
|
int64_t loop_count_9 = (int64_t)(loop_view_9).length;
|
|
int64_t loop_cursor_9 = 0LL;
|
|
while (loop_cursor_9 < loop_count_9) {
|
|
int64_t loop_index_9 = loop_cursor_9;
|
|
String entry = ((String *)loop_view_9.data)[loop_index_9];
|
|
if (compiler_backend_cache_CompilerEnvironment(entry)) {
|
|
compiler_backend_cache_HashText(hash, entry);
|
|
}
|
|
loop_cursor_9 = (int64_t)((uint64_t)loop_cursor_9 + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
free((entries).data);
|
|
(entries).data = NULL;
|
|
entries.capacity = 0;
|
|
entries.count = 0;
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool value_8 = ok;
|
|
free((*value_3).data);
|
|
(*value_3).data = NULL;
|
|
(*value_3).capacity = 0;
|
|
(*value_3).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_8;
|
|
}
|
|
|
|
__type_838711075b90279a
|
|
compiler_backend_cache_Probe(Slice arguments, bool piped)
|
|
{
|
|
__type_c53c2d7c4913dc02 command = {0};
|
|
__type_c53c2d7c4913dc02* value_0 = &command;
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(arguments).length; it_index++) {
|
|
String value = ((String *)arguments.data)[it_index];
|
|
String value_1 = value;
|
|
bool value_2 = false;
|
|
void *value_3 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_3 != NULL) {
|
|
(command).data = (String *)value_3;
|
|
(command).data[(command).count++] = value_1;
|
|
value_2 = true;
|
|
}
|
|
(void)value_2;
|
|
}
|
|
bool value_4 = piped;
|
|
if (value_4) {
|
|
bool value_5 = compiler_backend_cache_RequestedPipe(arguments);
|
|
value_4 = !value_5;
|
|
}
|
|
if (value_4) {
|
|
String value_6 = StringLiteral("-pipe");
|
|
bool value_7 = false;
|
|
void *value_8 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_8 != NULL) {
|
|
(command).data = (String *)value_8;
|
|
(command).data[(command).count++] = value_6;
|
|
value_7 = true;
|
|
}
|
|
(void)value_7;
|
|
}
|
|
String value_9 = StringLiteral("-v");
|
|
bool value_10 = false;
|
|
void *value_11 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_11 != NULL) {
|
|
(command).data = (String *)value_11;
|
|
(command).data[(command).count++] = value_9;
|
|
value_10 = true;
|
|
}
|
|
(void)value_10;
|
|
String value_12 = StringLiteral("-x");
|
|
bool value_13 = false;
|
|
void *value_14 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_14 != NULL) {
|
|
(command).data = (String *)value_14;
|
|
(command).data[(command).count++] = value_12;
|
|
value_13 = true;
|
|
}
|
|
(void)value_13;
|
|
String value_15 = StringLiteral("c");
|
|
bool value_16 = false;
|
|
void *value_17 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_17 != NULL) {
|
|
(command).data = (String *)value_17;
|
|
(command).data[(command).count++] = value_15;
|
|
value_16 = true;
|
|
}
|
|
(void)value_16;
|
|
String value_18 = StringLiteral("-c");
|
|
bool value_19 = false;
|
|
void *value_20 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_20 != NULL) {
|
|
(command).data = (String *)value_20;
|
|
(command).data[(command).count++] = value_18;
|
|
value_19 = true;
|
|
}
|
|
(void)value_19;
|
|
String value_21 = StringLiteral("/dev/null");
|
|
bool value_22 = false;
|
|
void *value_23 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_23 != NULL) {
|
|
(command).data = (String *)value_23;
|
|
(command).data[(command).count++] = value_21;
|
|
value_22 = true;
|
|
}
|
|
(void)value_22;
|
|
String value_24 = StringLiteral("-o");
|
|
bool value_25 = false;
|
|
void *value_26 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_26 != NULL) {
|
|
(command).data = (String *)value_26;
|
|
(command).data[(command).count++] = value_24;
|
|
value_25 = true;
|
|
}
|
|
(void)value_25;
|
|
String value_27 = StringLiteral("/dev/null");
|
|
bool value_28 = false;
|
|
void *value_29 = ZirVecGrow((void *)(command).data, &(command).capacity, (command).count, sizeof(*(command).data));
|
|
if (value_29 != NULL) {
|
|
(command).data = (String *)value_29;
|
|
(command).data[(command).count++] = value_27;
|
|
value_28 = true;
|
|
}
|
|
(void)value_28;
|
|
__type_838711075b90279a result = {0};
|
|
__type_838711075b90279a* value_30 = &result;
|
|
ProcessOptions value_31 = {0};
|
|
Slice value_32 = {(command).data, (command).count};
|
|
value_31.arguments = SliceRange(value_32, 0LL, command.count, sizeof(*(command).data));
|
|
value_31.capture_output = true;
|
|
value_31.merge_error = true;
|
|
ProcessOptions options = value_31;
|
|
ProcessRun run = {0};
|
|
bool value_33 = process_run_linux_RunProcess(options, &(run));
|
|
if (value_33 && run.code == 0) {
|
|
{
|
|
Slice value_34 = {(run.output).data, (run.output).count};
|
|
Slice loop_view_18 = SliceRange(value_34, 0LL, run.output.count, sizeof(*(run.output).data));
|
|
int64_t loop_count_18 = (int64_t)(loop_view_18).length;
|
|
int64_t loop_cursor_18 = 0LL;
|
|
while (loop_cursor_18 < loop_count_18) {
|
|
int64_t loop_index_18 = loop_cursor_18;
|
|
uint8_t byte = ((uint8_t *)loop_view_18.data)[loop_index_18];
|
|
uint8_t value_35 = byte;
|
|
bool value_36 = false;
|
|
void *value_37 = ZirVecGrow((void *)(result).data, &(result).capacity, (result).count, sizeof(*(result).data));
|
|
if (value_37 != NULL) {
|
|
(result).data = (uint8_t *)value_37;
|
|
(result).data[(result).count++] = value_35;
|
|
value_36 = true;
|
|
}
|
|
(void)value_36;
|
|
loop_cursor_18 = (int64_t)((uint64_t)loop_cursor_18 + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
String value_38 = StringView(NULL, 0);
|
|
if (piped) {
|
|
value_38 = StringLiteral("native_probe_pipe");
|
|
} else {
|
|
value_38 = StringLiteral("native_probe_compile");
|
|
}
|
|
compiler_backend_cache_ProfileCount(value_38);
|
|
free((run.output).data);
|
|
(run.output).data = NULL;
|
|
run.output.capacity = 0;
|
|
run.output.count = 0;
|
|
free((command).data);
|
|
(command).data = NULL;
|
|
command.capacity = 0;
|
|
command.count = 0;
|
|
if (result.count > 65536LL) {
|
|
free((result).data);
|
|
(result).data = NULL;
|
|
result.capacity = 0;
|
|
result.count = 0;
|
|
__type_838711075b90279a value_39 = (__type_838711075b90279a){0};
|
|
free((run).output.data);
|
|
(run).output.data = NULL;
|
|
(run).output.capacity = 0;
|
|
(run).output.count = 0;
|
|
free((*value_30).data);
|
|
(*value_30).data = NULL;
|
|
(*value_30).capacity = 0;
|
|
(*value_30).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_39;
|
|
}
|
|
for (int64_t it_index = 0LL; it_index < result.count; it_index++) {
|
|
uint8_t byte = ZIRAN_VEC_INDEX((result).data, (result).count, it_index);
|
|
if (byte == 0) {
|
|
free((result).data);
|
|
(result).data = NULL;
|
|
result.capacity = 0;
|
|
result.count = 0;
|
|
__type_838711075b90279a value_40 = (__type_838711075b90279a){0};
|
|
free((run).output.data);
|
|
(run).output.data = NULL;
|
|
(run).output.capacity = 0;
|
|
(run).output.count = 0;
|
|
free((*value_30).data);
|
|
(*value_30).data = NULL;
|
|
(*value_30).capacity = 0;
|
|
(*value_30).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_40;
|
|
}
|
|
}
|
|
__type_838711075b90279a value_41 = result;
|
|
result.data = NULL;
|
|
result.capacity = 0;
|
|
result.count = 0;
|
|
__type_838711075b90279a value_42 = value_41;
|
|
free((run).output.data);
|
|
(run).output.data = NULL;
|
|
(run).output.capacity = 0;
|
|
(run).output.count = 0;
|
|
free((*value_30).data);
|
|
(*value_30).data = NULL;
|
|
(*value_30).capacity = 0;
|
|
(*value_30).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_42;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_HashProbeOutput(HashState* hash, String text)
|
|
{
|
|
__type_c53c2d7c4913dc02 lines = text_tools_TextLines(text);
|
|
__type_c53c2d7c4913dc02* value_0 = &lines;
|
|
if (lines.count == 0LL || lines.count > 16384LL) {
|
|
free((lines).data);
|
|
(lines).data = NULL;
|
|
lines.capacity = 0;
|
|
lines.count = 0;
|
|
bool value_1 = false;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_1;
|
|
}
|
|
bool value_2 = compiler_backend_cache_JoinProbeVersions(&(lines));
|
|
if (!value_2) {
|
|
free((lines).data);
|
|
(lines).data = NULL;
|
|
lines.capacity = 0;
|
|
lines.count = 0;
|
|
bool value_3 = false;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_3;
|
|
}
|
|
Slice value_4 = {(lines).data, (lines).count};
|
|
sort_SortText(SliceRange(value_4, 0LL, lines.count, sizeof(*(lines).data)));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(lines.count));
|
|
{
|
|
Slice value_5 = {(lines).data, (lines).count};
|
|
Slice value_6 = SliceRange(value_5, 0LL, lines.count, sizeof(*(lines).data));
|
|
Slice loop_view_11 = value_6;
|
|
int64_t loop_count_11 = (int64_t)(loop_view_11).length;
|
|
int64_t loop_cursor_11 = 0LL;
|
|
while (loop_cursor_11 < loop_count_11) {
|
|
int64_t loop_index_11 = loop_cursor_11;
|
|
String line = ((String *)loop_view_11.data)[loop_index_11];
|
|
compiler_backend_cache_HashText(hash, line);
|
|
loop_cursor_11 = (int64_t)((uint64_t)loop_cursor_11 + UINT64_C(1));
|
|
}
|
|
}
|
|
free((lines).data);
|
|
(lines).data = NULL;
|
|
lines.capacity = 0;
|
|
lines.count = 0;
|
|
bool value_7 = true;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_7;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_JoinProbeVersions(__type_c53c2d7c4913dc02* lines)
|
|
{
|
|
String prefix = StringLiteral("\tcompiled by GNU C version ");
|
|
String checksum_label = StringLiteral("Compiler executable checksum: ");
|
|
String assembler_label = StringLiteral("GNU assembler version ");
|
|
String gmp_label = StringLiteral("GMP version ");
|
|
String bfd_label = StringLiteral(" using BFD version ");
|
|
{
|
|
int64_t range_first_5 = 0LL;
|
|
int64_t range_last_5 = (int64_t)((uint64_t)(lines->count) - UINT64_C(2));
|
|
int64_t index = range_first_5;
|
|
if (index <= range_last_5) for (;;) {
|
|
int64_t banner_at = -1LL;
|
|
bool value_0 = text_tools_TextHasPrefix(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index), prefix);
|
|
if (value_0 && text_tools_TextHasPrefix(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1)))), gmp_label)) {
|
|
banner_at = text_tools_TextFind(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index), assembler_label, (int64_t)(prefix).length);
|
|
if (banner_at <= (int64_t)(prefix).length) {
|
|
if (index == range_last_5) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
bool value_1 = (uint8_t)ZIRAN_INDEX(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index).data, ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index).length, ((int64_t)((uint64_t)banner_at - UINT64_C(2)))) != 44;
|
|
if (value_1 || (uint8_t)ZIRAN_INDEX(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index).data, ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index).length, ((int64_t)((uint64_t)banner_at - UINT64_C(1)))) != 32) {
|
|
if (index == range_last_5) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
} else if (text_tools_TextHasPrefix(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index), checksum_label)) {
|
|
banner_at = text_tools_TextFind(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index), assembler_label, (int64_t)(checksum_label).length);
|
|
if (banner_at < 0LL) {
|
|
if (index == range_last_5) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
int64_t before = (int64_t)((uint64_t)banner_at - (uint64_t)((int64_t)(checksum_label).length));
|
|
int64_t after = 0LL;
|
|
while (true) {
|
|
int64_t value_2 = (int64_t)(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1))))).length;
|
|
if (!(after < value_2 && (uint8_t)ZIRAN_INDEX(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1)))).data, ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1)))).length, after) != 13)) { break; }
|
|
after = (int64_t)((uint64_t)after + UINT64_C(1));
|
|
}
|
|
if ((int64_t)((uint64_t)before + (uint64_t)after) != 32LL) {
|
|
if (index == range_last_5) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
bool digits = true;
|
|
{
|
|
int64_t range_first_30 = 0LL;
|
|
int64_t range_last_30 = (int64_t)((uint64_t)before - UINT64_C(1));
|
|
int64_t at = range_first_30;
|
|
if (at <= range_last_30) for (;;) {
|
|
uint8_t byte = (uint8_t)ZIRAN_INDEX(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index).data, ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index).length, ((int64_t)((uint64_t)((int64_t)(checksum_label).length) + (uint64_t)at)));
|
|
bool hex = (byte >= 48 && byte <= 57) || (byte >= 97 && byte <= 102);
|
|
if (!hex) {
|
|
digits = false;
|
|
}
|
|
if (at == range_last_30) {
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
{
|
|
int64_t range_first_37 = 0LL;
|
|
int64_t range_last_37 = (int64_t)((uint64_t)after - UINT64_C(1));
|
|
int64_t at = range_first_37;
|
|
if (at <= range_last_37) for (;;) {
|
|
uint8_t next_byte = (uint8_t)ZIRAN_INDEX(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1)))).data, ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1)))).length, at);
|
|
bool next_hex = (next_byte >= 48 && next_byte <= 57) || (next_byte >= 97 && next_byte <= 102);
|
|
if (!next_hex) {
|
|
digits = false;
|
|
}
|
|
if (at == range_last_37) {
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
if (!digits) {
|
|
if (index == range_last_5) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
} else {
|
|
if (index == range_last_5) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
String value_3 = ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index);
|
|
String value_4 = StringRange(value_3, (int64_t)banner_at, (int64_t)value_3.length);
|
|
bool value_5 = false;
|
|
{
|
|
String value = value_4;
|
|
String piece = bfd_label;
|
|
value_5 = text_tools_TextContains(value, piece);
|
|
}
|
|
if (!value_5) {
|
|
if (index == range_last_5) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
continue;
|
|
}
|
|
String value_7 = ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index);
|
|
Text saved = vec_TextCopy(StringRange(value_7, (int64_t)banner_at, (int64_t)value_7.length));
|
|
if (saved.bytes.count == 0LL) {
|
|
bool value_8 = false;
|
|
free((saved).bytes.data);
|
|
(saved).bytes.data = NULL;
|
|
(saved).bytes.capacity = 0;
|
|
(saved).bytes.count = 0;
|
|
return value_8;
|
|
}
|
|
String value_9 = ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, index);
|
|
Text rebuilt = vec_TextCopy(StringRange(value_9, (int64_t)0LL, (int64_t)banner_at));
|
|
bool value_10 = false;
|
|
if ((ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1))))).length == 0) {
|
|
value_10 = true;
|
|
} else {
|
|
void *value_11 = ZirVecReserve((void *)(rebuilt.bytes).data, &(rebuilt.bytes).capacity, (rebuilt.bytes).count, (int64_t)(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1))))).length, sizeof(*(rebuilt.bytes).data));
|
|
if (value_11 != NULL) {
|
|
(rebuilt.bytes).data = (uint8_t *)value_11;
|
|
memcpy((rebuilt.bytes).data + (rebuilt.bytes).count, (ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1))))).data, (size_t)(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1))))).length);
|
|
(rebuilt.bytes).count += (int64_t)(ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, ((int64_t)((uint64_t)index + UINT64_C(1))))).length;
|
|
value_10 = true;
|
|
}
|
|
}
|
|
(void)value_10;
|
|
__type_c53c2d7c4913dc02 merged = {0};
|
|
__type_c53c2d7c4913dc02* value_12 = &merged;
|
|
Text value_13 = rebuilt;
|
|
(rebuilt).bytes.data = NULL;
|
|
(rebuilt).bytes.capacity = 0;
|
|
(rebuilt).bytes.count = 0;
|
|
String value_14 = vec_TextDetach(value_13);
|
|
String value_15 = value_14;
|
|
bool value_16 = false;
|
|
void *value_17 = ZirVecGrow((void *)(merged).data, &(merged).capacity, (merged).count, sizeof(*(merged).data));
|
|
if (value_17 != NULL) {
|
|
(merged).data = (String *)value_17;
|
|
(merged).data[(merged).count++] = value_15;
|
|
value_16 = true;
|
|
}
|
|
(void)value_16;
|
|
Text value_18 = saved;
|
|
(saved).bytes.data = NULL;
|
|
(saved).bytes.capacity = 0;
|
|
(saved).bytes.count = 0;
|
|
String value_19 = vec_TextDetach(value_18);
|
|
String value_20 = value_19;
|
|
bool value_21 = false;
|
|
void *value_22 = ZirVecGrow((void *)(merged).data, &(merged).capacity, (merged).count, sizeof(*(merged).data));
|
|
if (value_22 != NULL) {
|
|
(merged).data = (String *)value_22;
|
|
(merged).data[(merged).count++] = value_20;
|
|
value_21 = true;
|
|
}
|
|
(void)value_21;
|
|
__type_c53c2d7c4913dc02 tail = {0};
|
|
__type_c53c2d7c4913dc02* value_23 = &tail;
|
|
__type_c53c2d7c4913dc02 value_24 = merged;
|
|
merged = tail;
|
|
tail = value_24;
|
|
__type_c53c2d7c4913dc02 head = {0};
|
|
__type_c53c2d7c4913dc02* value_25 = &head;
|
|
{
|
|
int64_t range_first_66 = 0LL;
|
|
int64_t range_last_66 = (int64_t)((uint64_t)index - UINT64_C(1));
|
|
int64_t at = range_first_66;
|
|
if (at <= range_last_66) for (;;) {
|
|
String value_26 = ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, at);
|
|
bool value_27 = false;
|
|
void *value_28 = ZirVecGrow((void *)(head).data, &(head).capacity, (head).count, sizeof(*(head).data));
|
|
if (value_28 != NULL) {
|
|
(head).data = (String *)value_28;
|
|
(head).data[(head).count++] = value_26;
|
|
value_27 = true;
|
|
}
|
|
(void)value_27;
|
|
if (at == range_last_66) {
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
String value_29 = ZIRAN_VEC_INDEX((tail).data, (tail).count, 0);
|
|
bool value_30 = false;
|
|
void *value_31 = ZirVecGrow((void *)(head).data, &(head).capacity, (head).count, sizeof(*(head).data));
|
|
if (value_31 != NULL) {
|
|
(head).data = (String *)value_31;
|
|
(head).data[(head).count++] = value_29;
|
|
value_30 = true;
|
|
}
|
|
(void)value_30;
|
|
String value_32 = ZIRAN_VEC_INDEX((tail).data, (tail).count, 1);
|
|
bool value_33 = false;
|
|
void *value_34 = ZirVecGrow((void *)(head).data, &(head).capacity, (head).count, sizeof(*(head).data));
|
|
if (value_34 != NULL) {
|
|
(head).data = (String *)value_34;
|
|
(head).data[(head).count++] = value_32;
|
|
value_33 = true;
|
|
}
|
|
(void)value_33;
|
|
{
|
|
int64_t range_first_71 = (int64_t)((uint64_t)index + UINT64_C(2));
|
|
int64_t range_last_71 = (int64_t)((uint64_t)(lines->count) - UINT64_C(1));
|
|
int64_t at = range_first_71;
|
|
if (at <= range_last_71) for (;;) {
|
|
String value_35 = ZIRAN_VEC_INDEX((*(lines)).data, (*(lines)).count, at);
|
|
bool value_36 = false;
|
|
void *value_37 = ZirVecGrow((void *)(head).data, &(head).capacity, (head).count, sizeof(*(head).data));
|
|
if (value_37 != NULL) {
|
|
(head).data = (String *)value_37;
|
|
(head).data[(head).count++] = value_35;
|
|
value_36 = true;
|
|
}
|
|
(void)value_36;
|
|
if (at == range_last_71) {
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
}
|
|
__type_c53c2d7c4913dc02 value_38 = head;
|
|
head = (*(lines));
|
|
(*(lines)) = value_38;
|
|
free((head).data);
|
|
(head).data = NULL;
|
|
head.capacity = 0;
|
|
head.count = 0;
|
|
free((tail).data);
|
|
(tail).data = NULL;
|
|
tail.capacity = 0;
|
|
tail.count = 0;
|
|
if (index == range_last_5) {
|
|
free((*value_25).data);
|
|
(*value_25).data = NULL;
|
|
(*value_25).capacity = 0;
|
|
(*value_25).count = 0;
|
|
free((*value_23).data);
|
|
(*value_23).data = NULL;
|
|
(*value_23).capacity = 0;
|
|
(*value_23).count = 0;
|
|
free((*value_12).data);
|
|
(*value_12).data = NULL;
|
|
(*value_12).capacity = 0;
|
|
(*value_12).count = 0;
|
|
free((rebuilt).bytes.data);
|
|
(rebuilt).bytes.data = NULL;
|
|
(rebuilt).bytes.capacity = 0;
|
|
(rebuilt).bytes.count = 0;
|
|
free((saved).bytes.data);
|
|
(saved).bytes.data = NULL;
|
|
(saved).bytes.capacity = 0;
|
|
(saved).bytes.count = 0;
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
free((*value_25).data);
|
|
(*value_25).data = NULL;
|
|
(*value_25).capacity = 0;
|
|
(*value_25).count = 0;
|
|
free((*value_23).data);
|
|
(*value_23).data = NULL;
|
|
(*value_23).capacity = 0;
|
|
(*value_23).count = 0;
|
|
free((*value_12).data);
|
|
(*value_12).data = NULL;
|
|
(*value_12).capacity = 0;
|
|
(*value_12).count = 0;
|
|
free((rebuilt).bytes.data);
|
|
(rebuilt).bytes.data = NULL;
|
|
(rebuilt).bytes.capacity = 0;
|
|
(rebuilt).bytes.count = 0;
|
|
free((saved).bytes.data);
|
|
(saved).bytes.data = NULL;
|
|
(saved).bytes.capacity = 0;
|
|
(saved).bytes.count = 0;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
BuildCache*
|
|
compiler_backend_cache_Open(Slice arguments, String output, String executable)
|
|
{
|
|
if ((int64_t)(arguments).length == 0LL) {
|
|
return (void *)0;
|
|
}
|
|
bool value_0 = compiler_backend_cache_SupportedArguments(arguments);
|
|
if (!value_0) {
|
|
return (void *)0;
|
|
}
|
|
String compiler = compiler_backend_cache_Executable(((String *)arguments.data)[0]);
|
|
if ((int64_t)(compiler).length == 0LL) {
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
bool value_1 = compiler_backend_cache_NativeImage(compiler);
|
|
if (!value_1) {
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
String name = compiler_backend_cache_TextName(compiler);
|
|
String value_2 = StringLiteral("gcc");
|
|
bool value_3 = false;
|
|
{
|
|
String value = name;
|
|
String piece = value_2;
|
|
value_3 = text_tools_TextContains(value, piece);
|
|
}
|
|
bool value_5 = !value_3;
|
|
if (value_5) {
|
|
String value_6 = StringLiteral("clang");
|
|
bool value_7 = false;
|
|
{
|
|
String value = name;
|
|
String piece = value_6;
|
|
value_7 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_5 = !value_7;
|
|
}
|
|
if (value_5 && !StringEqual(name, StringLiteral("cc"))) {
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
String value_9 = StringLiteral("clang");
|
|
bool value_10 = false;
|
|
{
|
|
String value = name;
|
|
String piece = value_9;
|
|
value_10 = text_tools_TextContains(value, piece);
|
|
}
|
|
bool piped = !value_10;
|
|
void* value_12 = zir_f_36a3c20ab8e249b6_AllocateRaw(1, sizeof(BuildCache));
|
|
BuildCache* cache = (BuildCache*)(value_12);
|
|
if (cache == ((void *)0)) {
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
bool* value_13 = &(cache->piped);
|
|
(*value_13) = piped;
|
|
String resolved_output = compiler_backend_cache_Resolved(output);
|
|
if ((int64_t)(resolved_output).length == 0LL) {
|
|
compiler_backend_cache_Close(cache);
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
String* value_14 = &(cache->output);
|
|
(*value_14) = resolved_output;
|
|
String* value_15 = &(cache->executable);
|
|
String value_16 = compiler_backend_cache_Owned(executable);
|
|
(*value_15) = value_16;
|
|
ClockValue clock = {0};
|
|
int64_t value_17 = (int64_t)(cache->executable).length;
|
|
if (value_17 == 0LL) {
|
|
compiler_backend_cache_Close(cache);
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
if (zir_f_36a3c20ab8e249b6_ClockRaw(0, &(clock)) != 0) {
|
|
compiler_backend_cache_Close(cache);
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
int64_t* value_18 = &(cache->started_seconds);
|
|
(*value_18) = (int64_t)(clock.seconds);
|
|
int64_t* value_19 = &(cache->started_nanoseconds);
|
|
(*value_19) = (int64_t)(clock.nanoseconds);
|
|
HashState hash = compiler_backend_cache_HashNew();
|
|
compiler_backend_cache_HashText(&(hash), StringLiteral("Ziran native object cache 4"));
|
|
uint64_t value_20 = 0;
|
|
if (piped) {
|
|
value_20 = 1ULL;
|
|
} else {
|
|
value_20 = 0ULL;
|
|
}
|
|
compiler_backend_cache_HashInteger(&(hash), value_20);
|
|
uint8_t directory[4096] = {0};
|
|
uint8_t* working_pointer = zir_f_36a3c20ab8e249b6_CurrentDirectory(&(directory[0]), 4096);
|
|
int64_t working_length = 0LL;
|
|
if (working_pointer != ((void *)0)) {
|
|
while (ZIRAN_INDEX(directory, 4096, working_length) != 0) {
|
|
working_length = (int64_t)((uint64_t)working_length + UINT64_C(1));
|
|
}
|
|
}
|
|
if (working_length == 0LL) {
|
|
compiler_backend_cache_Close(cache);
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
Slice value_21 = {directory, 4096};
|
|
Slice value_22 = SliceRange(value_21, (int64_t)0LL, (int64_t)working_length, sizeof(uint8_t));
|
|
compiler_backend_cache_HashText(&(hash), StringView((const char *)(value_22).data, (size_t)(value_22).length));
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(arguments).length; it_index++) {
|
|
String argument = ((String *)arguments.data)[it_index];
|
|
compiler_backend_cache_HashText(&(hash), argument);
|
|
}
|
|
bool value_23 = compiler_backend_cache_HashEnvironment(&(hash));
|
|
if (!value_23) {
|
|
compiler_backend_cache_Close(cache);
|
|
compiler_backend_cache_Release(compiler);
|
|
return (void *)0;
|
|
}
|
|
PathInfo info = file_tree_linux_PathStatus(compiler, true);
|
|
compiler_backend_cache_HashText(&(hash), compiler);
|
|
HashState* value_24 = &(hash);
|
|
PathInfo value_25 = info;
|
|
{
|
|
HashState* hash = value_24;
|
|
PathInfo info = value_25;
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_major));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_minor));
|
|
compiler_backend_cache_HashInteger(hash, info.inode);
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.mode));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.size));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified_nanoseconds));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed_nanoseconds));
|
|
}
|
|
compiler_backend_cache_Release(compiler);
|
|
__type_838711075b90279a probe = compiler_backend_cache_Probe(arguments, piped);
|
|
__type_838711075b90279a* value_27 = &probe;
|
|
Slice value_28 = {(probe).data, (probe).count};
|
|
Slice value_29 = SliceRange(value_28, 0LL, probe.count, sizeof(*(probe).data));
|
|
String probe_text = StringView((const char *)(value_29).data, (size_t)(value_29).length);
|
|
bool value_30 = probe.count == 0LL;
|
|
bool value_31 = value_30;
|
|
if (!value_31) {
|
|
bool value_32 = piped;
|
|
bool value_33 = value_32;
|
|
if (value_33) {
|
|
bool value_34 = compiler_backend_cache_HashProbeOutput(&(hash), probe_text);
|
|
value_33 = !value_34;
|
|
}
|
|
value_31 = value_33;
|
|
}
|
|
if (value_31) {
|
|
free((probe).data);
|
|
(probe).data = NULL;
|
|
probe.capacity = 0;
|
|
probe.count = 0;
|
|
compiler_backend_cache_Close(cache);
|
|
BuildCache* value_35 = (void *)0;
|
|
free((*value_27).data);
|
|
(*value_27).data = NULL;
|
|
(*value_27).capacity = 0;
|
|
(*value_27).count = 0;
|
|
return value_35;
|
|
}
|
|
bool value_36 = compiler_backend_cache_ParseProbe(cache, &(hash), probe_text, piped);
|
|
if (!value_36) {
|
|
free((probe).data);
|
|
(probe).data = NULL;
|
|
probe.capacity = 0;
|
|
probe.count = 0;
|
|
compiler_backend_cache_Close(cache);
|
|
BuildCache* value_37 = (void *)0;
|
|
free((*value_27).data);
|
|
(*value_27).data = NULL;
|
|
(*value_27).capacity = 0;
|
|
(*value_27).count = 0;
|
|
return value_37;
|
|
}
|
|
free((probe).data);
|
|
(probe).data = NULL;
|
|
probe.capacity = 0;
|
|
probe.count = 0;
|
|
bool value_38 = compiler_backend_cache_AppendOwned(&(cache->roots), cache->output);
|
|
if (!value_38) {
|
|
compiler_backend_cache_Close(cache);
|
|
BuildCache* value_39 = (void *)0;
|
|
free((*value_27).data);
|
|
(*value_27).data = NULL;
|
|
(*value_27).capacity = 0;
|
|
(*value_27).count = 0;
|
|
return value_39;
|
|
}
|
|
compiler_backend_cache_HashFinish(&(hash), &(cache->identity));
|
|
BuildCache* value_40 = cache;
|
|
free((*value_27).data);
|
|
(*value_27).data = NULL;
|
|
(*value_27).capacity = 0;
|
|
(*value_27).count = 0;
|
|
return value_40;
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_HashSnapshot(HashState* hash, PathInfo info)
|
|
{
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_major));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_minor));
|
|
compiler_backend_cache_HashInteger(hash, info.inode);
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.mode));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.size));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified_nanoseconds));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed_nanoseconds));
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_ToolFromLine(String line)
|
|
{
|
|
String value = text_tools_TextTrim(line);
|
|
if ((int64_t)(value).length == 0LL) {
|
|
return StringLiteral("");
|
|
}
|
|
if ((uint8_t)value.data[0] == 34) {
|
|
int64_t end = text_tools_TextFind(value, StringLiteral("\""), 1LL);
|
|
if (end < 0LL) {
|
|
return StringLiteral("");
|
|
}
|
|
return StringRange(value, (int64_t)1LL, (int64_t)end);
|
|
}
|
|
int64_t at = 0LL;
|
|
while (true) {
|
|
bool value_0 = at < (int64_t)(value).length;
|
|
if (value_0) {
|
|
bool value_1 = text_tools_TextIsSpace((uint8_t)ZIRAN_INDEX(value.data, value.length, at));
|
|
value_0 = !value_1;
|
|
}
|
|
if (!value_0) { break; }
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
return StringRange(value, (int64_t)0LL, (int64_t)at);
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_ParseProbe(BuildCache* cache, HashState* hash, String text, bool piped)
|
|
{
|
|
__type_c53c2d7c4913dc02 programs = {0};
|
|
__type_c53c2d7c4913dc02* value_0 = &programs;
|
|
bool searching = false;
|
|
bool ended = false;
|
|
int64_t tools = 0LL;
|
|
bool ok = true;
|
|
__type_c53c2d7c4913dc02 lines = text_tools_TextLines(text);
|
|
__type_c53c2d7c4913dc02* value_1 = &lines;
|
|
for (int64_t it_index = 0LL; it_index < lines.count; it_index++) {
|
|
String line = ZIRAN_VEC_INDEX((lines).data, (lines).count, it_index);
|
|
if (!ok) {
|
|
break;
|
|
}
|
|
String value_2 = StringLiteral("COLLECT_GCC=");
|
|
bool value_3 = false;
|
|
{
|
|
String value = line;
|
|
String prefix = value_2;
|
|
value_3 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
if (value_3) {
|
|
String resolved = compiler_backend_cache_Executable(StringRange(line, (int64_t)12LL, (int64_t)(int64_t)(line).length));
|
|
if ((int64_t)(resolved).length == 0LL) {
|
|
ok = false;
|
|
} else {
|
|
PathInfo value_5 = file_tree_linux_PathStatus(resolved, true);
|
|
if (((PathKind)(value_5.kind)) != ((PathKind)(1))) {
|
|
ok = false;
|
|
} else {
|
|
bool value_6 = compiler_backend_cache_AppendOwned(&(programs), resolved);
|
|
if (!value_6) {
|
|
ok = false;
|
|
}
|
|
}
|
|
}
|
|
compiler_backend_cache_Release(resolved);
|
|
} else {
|
|
String value_7 = StringLiteral("#include ");
|
|
bool value_8 = false;
|
|
{
|
|
String value = line;
|
|
String prefix = value_7;
|
|
value_8 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
if (value_8) {
|
|
searching = true;
|
|
} else if (StringEqual(line, StringLiteral("End of search list."))) {
|
|
searching = false;
|
|
ended = true;
|
|
} else if (searching && (int64_t)(line).length > 0LL && (uint8_t)ZIRAN_INDEX(line.data, line.length, 0) == 32) {
|
|
String path = text_tools_TextTrim(line);
|
|
int64_t framework = text_tools_TextFind(path, StringLiteral(" (framework directory)"), 0LL);
|
|
if (framework >= 0LL) {
|
|
path = StringRange(path, (int64_t)0LL, (int64_t)framework);
|
|
}
|
|
bool value_10 = piped;
|
|
bool value_11 = value_10;
|
|
if (value_11) {
|
|
PathInfo value_12 = file_tree_linux_PathStatus(path, true);
|
|
value_11 = (((PathKind)(value_12.kind)) != ((PathKind)(2)));
|
|
}
|
|
if (value_11) {
|
|
ok = false;
|
|
}
|
|
bool value_13 = ok;
|
|
if (value_13 && compiler_backend_cache_AppendOwned(&(cache->roots), path)) {
|
|
compiler_backend_cache_HashText(hash, path);
|
|
} else {
|
|
ok = false;
|
|
}
|
|
} else {
|
|
bool value_14 = searching && piped;
|
|
bool value_15 = value_14;
|
|
if (value_15) {
|
|
String value_16 = StringLiteral("GNU assembler version ");
|
|
bool value_17 = false;
|
|
{
|
|
String value = line;
|
|
String prefix = value_16;
|
|
value_17 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
value_15 = value_17;
|
|
}
|
|
bool value_19 = value_15;
|
|
bool value_20 = value_19;
|
|
if (value_20) {
|
|
String value_21 = StringLiteral(" using BFD version ");
|
|
bool value_22 = false;
|
|
{
|
|
String value = line;
|
|
String piece = value_21;
|
|
value_22 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_20 = value_22;
|
|
}
|
|
if (value_20) {
|
|
} else if (searching && piped) {
|
|
ok = false;
|
|
} else {
|
|
String value_24 = StringLiteral("ignoring nonexistent directory \"");
|
|
bool value_25 = false;
|
|
{
|
|
String value = line;
|
|
String prefix = value_24;
|
|
value_25 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
if (value_25) {
|
|
int64_t first = text_tools_TextFind(line, StringLiteral("\""), 0LL);
|
|
int64_t last = text_tools_TextFindLast(line, StringLiteral("\""));
|
|
if (first >= 0LL && last > first) {
|
|
String path = StringRange(line, (int64_t)((int64_t)((uint64_t)first + UINT64_C(1))), (int64_t)last);
|
|
if (compiler_backend_cache_AppendOwned(&(cache->roots), path)) {
|
|
compiler_backend_cache_HashText(hash, path);
|
|
} else {
|
|
ok = false;
|
|
}
|
|
}
|
|
} else if (StringEqual(line, StringLiteral(" (in-process)"))) {
|
|
} else {
|
|
bool value_27 = (int64_t)(line).length > 1LL && (uint8_t)ZIRAN_INDEX(line.data, line.length, 0) == 32;
|
|
bool value_28 = value_27;
|
|
if (value_28) {
|
|
bool value_29 = text_tools_TextIsSpace((uint8_t)ZIRAN_INDEX(line.data, line.length, 1));
|
|
value_28 = !value_29;
|
|
}
|
|
if (value_28) {
|
|
String tool = compiler_backend_cache_ToolFromLine(line);
|
|
if ((int64_t)(tool).length > 0LL) {
|
|
String resolved = compiler_backend_cache_Executable(tool);
|
|
if ((int64_t)(resolved).length == 0LL) {
|
|
ok = false;
|
|
} else {
|
|
bool value_30 = compiler_backend_cache_NativeImage(resolved);
|
|
if (!value_30) {
|
|
ok = false;
|
|
} else {
|
|
PathInfo value_31 = file_tree_linux_PathStatus(resolved, true);
|
|
if (((PathKind)(value_31.kind)) != ((PathKind)(1))) {
|
|
ok = false;
|
|
} else if (compiler_backend_cache_AppendOwned(&(programs), resolved)) {
|
|
tools = (int64_t)((uint64_t)tools + UINT64_C(1));
|
|
} else {
|
|
ok = false;
|
|
}
|
|
}
|
|
}
|
|
compiler_backend_cache_Release(resolved);
|
|
}
|
|
} else {
|
|
bool value_32 = !piped;
|
|
bool value_33 = value_32;
|
|
if (value_33) {
|
|
String value_34 = StringLiteral("Compiler executable checksum:");
|
|
bool value_35 = false;
|
|
{
|
|
String value = line;
|
|
String prefix = value_34;
|
|
value_35 = text_tools_TextHasPrefix(value, prefix);
|
|
}
|
|
bool value_37 = value_35;
|
|
if (!value_37) {
|
|
String value_38 = StringLiteral(" version ");
|
|
bool value_39 = false;
|
|
{
|
|
String value = line;
|
|
String piece = value_38;
|
|
value_39 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_37 = value_39;
|
|
}
|
|
value_33 = value_37;
|
|
}
|
|
if (value_33) {
|
|
compiler_backend_cache_HashText(hash, line);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
free((lines).data);
|
|
(lines).data = NULL;
|
|
lines.capacity = 0;
|
|
lines.count = 0;
|
|
if (!ok) {
|
|
compiler_backend_cache_ClearNames(&(programs));
|
|
bool value_41 = false;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_41;
|
|
}
|
|
if (!ended) {
|
|
compiler_backend_cache_ClearNames(&(programs));
|
|
bool value_42 = false;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_42;
|
|
}
|
|
if (tools < 1LL) {
|
|
compiler_backend_cache_ClearNames(&(programs));
|
|
bool value_43 = false;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_43;
|
|
}
|
|
if (piped && tools < 2LL) {
|
|
compiler_backend_cache_ClearNames(&(programs));
|
|
bool value_44 = false;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_44;
|
|
}
|
|
Slice value_45 = {(programs).data, (programs).count};
|
|
sort_SortText(SliceRange(value_45, 0LL, programs.count, sizeof(*(programs).data)));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(programs.count));
|
|
{
|
|
int64_t range_first_111 = 0LL;
|
|
int64_t range_last_111 = (int64_t)((uint64_t)(programs.count) - UINT64_C(1));
|
|
int64_t index = range_first_111;
|
|
if (index <= range_last_111) for (;;) {
|
|
String path = ZIRAN_VEC_INDEX((programs).data, (programs).count, index);
|
|
PathInfo info = file_tree_linux_PathStatus(path, true);
|
|
if (((PathKind)(info.kind)) != ((PathKind)(1))) {
|
|
compiler_backend_cache_ClearNames(&(programs));
|
|
bool value_46 = false;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_46;
|
|
}
|
|
compiler_backend_cache_HashText(hash, path);
|
|
HashState* value_47 = hash;
|
|
PathInfo value_48 = info;
|
|
{
|
|
HashState* hash = value_47;
|
|
PathInfo info = value_48;
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_major));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.device_minor));
|
|
compiler_backend_cache_HashInteger(hash, info.inode);
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.mode));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.size));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.modified_nanoseconds));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed));
|
|
compiler_backend_cache_HashInteger(hash, (uint64_t)(info.changed_nanoseconds));
|
|
}
|
|
if (index == range_last_111) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
compiler_backend_cache_ClearNames(&(programs));
|
|
__type_c53c2d7c4913dc02 resolved_roots = {0};
|
|
__type_c53c2d7c4913dc02* value_50 = &resolved_roots;
|
|
{
|
|
Slice value_51 = {(cache->roots).data, (cache->roots).count};
|
|
Slice value_52 = SliceRange(value_51, 0LL, cache->roots.count, sizeof(*(cache->roots).data));
|
|
Slice loop_view_123 = value_52;
|
|
int64_t loop_count_123 = (int64_t)(loop_view_123).length;
|
|
int64_t loop_cursor_123 = 0LL;
|
|
while (loop_cursor_123 < loop_count_123) {
|
|
int64_t loop_index_123 = loop_cursor_123;
|
|
String root = ((String *)loop_view_123.data)[loop_index_123];
|
|
String resolved = compiler_backend_cache_Resolved(root);
|
|
if ((int64_t)(resolved).length > 0LL) {
|
|
bool value_53 = compiler_backend_cache_AppendOwned(&(resolved_roots), resolved);
|
|
if (!value_53) {
|
|
compiler_backend_cache_Release(resolved);
|
|
compiler_backend_cache_ClearNames(&(resolved_roots));
|
|
bool value_54 = false;
|
|
free((*value_50).data);
|
|
(*value_50).data = NULL;
|
|
(*value_50).capacity = 0;
|
|
(*value_50).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_54;
|
|
}
|
|
} else {
|
|
bool value_55 = compiler_backend_cache_AppendOwned(&(resolved_roots), root);
|
|
if (!value_55) {
|
|
compiler_backend_cache_ClearNames(&(resolved_roots));
|
|
bool value_56 = false;
|
|
free((*value_50).data);
|
|
(*value_50).data = NULL;
|
|
(*value_50).capacity = 0;
|
|
(*value_50).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_56;
|
|
}
|
|
}
|
|
compiler_backend_cache_Release(resolved);
|
|
loop_cursor_123 = (int64_t)((uint64_t)loop_cursor_123 + UINT64_C(1));
|
|
}
|
|
}
|
|
__type_c53c2d7c4913dc02 value_57 = resolved_roots;
|
|
resolved_roots = cache->roots;
|
|
cache->roots = value_57;
|
|
free((resolved_roots).data);
|
|
(resolved_roots).data = NULL;
|
|
resolved_roots.capacity = 0;
|
|
resolved_roots.count = 0;
|
|
bool value_58 = true;
|
|
free((*value_50).data);
|
|
(*value_50).data = NULL;
|
|
(*value_50).capacity = 0;
|
|
(*value_50).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_58;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_SpellingKey(BuildCache* cache, HashState* hash, String spelling, __type_c53c2d7c4913dc02* parents, bool* recordable)
|
|
{
|
|
int64_t item = compiler_backend_cache_SpellingDigest(cache, spelling, StringLiteral(""));
|
|
if (item < 0LL) {
|
|
return false;
|
|
}
|
|
HashState* value_0 = hash;
|
|
Slice value_1 = {((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, item)).digest).bytes, 32};
|
|
Slice value_2 = value_1;
|
|
compiler_backend_cache_HashBytes(value_0, StringView((const char *)(value_2).data, (size_t)(value_2).length));
|
|
if ((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, item)).recent) {
|
|
bool* value_3 = &((*(recordable)));
|
|
(*value_3) = false;
|
|
}
|
|
__type_c53c2d7c4913dc02 parent_values = {0};
|
|
__type_c53c2d7c4913dc02* value_4 = &parent_values;
|
|
__type_c53c2d7c4913dc02 value_5 = parent_values;
|
|
parent_values = (*(parents));
|
|
(*(parents)) = value_5;
|
|
for (int64_t it_index = 0LL; it_index < parent_values.count; it_index++) {
|
|
String parent = ZIRAN_VEC_INDEX((parent_values).data, (parent_values).count, it_index);
|
|
int64_t item = compiler_backend_cache_SpellingDigest(cache, spelling, parent);
|
|
if (item < 0LL) {
|
|
__type_c53c2d7c4913dc02 value_6 = parent_values;
|
|
parent_values = (*(parents));
|
|
(*(parents)) = value_6;
|
|
bool value_7 = false;
|
|
free((*value_4).data);
|
|
(*value_4).data = NULL;
|
|
(*value_4).capacity = 0;
|
|
(*value_4).count = 0;
|
|
return value_7;
|
|
}
|
|
HashState* value_8 = hash;
|
|
Slice value_9 = {((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, item)).digest).bytes, 32};
|
|
Slice value_10 = value_9;
|
|
compiler_backend_cache_HashBytes(value_8, StringView((const char *)(value_10).data, (size_t)(value_10).length));
|
|
if ((ZIRAN_VEC_INDEX((cache->candidates).data, (cache->candidates).count, item)).recent) {
|
|
bool* value_11 = &((*(recordable)));
|
|
(*value_11) = false;
|
|
}
|
|
}
|
|
__type_c53c2d7c4913dc02 value_12 = parent_values;
|
|
parent_values = (*(parents));
|
|
(*(parents)) = value_12;
|
|
bool value_13 = true;
|
|
free((*value_4).data);
|
|
(*value_4).data = NULL;
|
|
(*value_4).capacity = 0;
|
|
(*value_4).count = 0;
|
|
return value_13;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_LookupDigest(BuildCache* cache, __type_c53c2d7c4913dc02* dependencies, Digest* output, bool recording)
|
|
{
|
|
__type_c53c2d7c4913dc02 parents = {0};
|
|
__type_c53c2d7c4913dc02* value_0 = &parents;
|
|
__type_c53c2d7c4913dc02 pending = {0};
|
|
__type_c53c2d7c4913dc02* value_1 = &pending;
|
|
__type_c53c2d7c4913dc02 value_2 = pending;
|
|
pending = (*(dependencies));
|
|
(*(dependencies)) = value_2;
|
|
HashState hash = compiler_backend_cache_HashNew();
|
|
bool recordable = true;
|
|
bool ok = true;
|
|
for (int64_t it_index = 0LL; it_index < pending.count; it_index++) {
|
|
String dependency = ZIRAN_VEC_INDEX((pending).data, (pending).count, it_index);
|
|
int64_t item = compiler_backend_cache_FileFind(cache, dependency, false);
|
|
if (item < 0LL) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
int64_t value_3 = (int64_t)((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).parent).length;
|
|
if (value_3 == 0LL) {
|
|
String resolved = compiler_backend_cache_Resolved(dependency);
|
|
bool value_4 = (int64_t)(resolved).length > 0LL;
|
|
if (value_4) {
|
|
String value_5 = StringLiteral("/.objects/");
|
|
bool value_6 = false;
|
|
{
|
|
String value = resolved;
|
|
String piece = value_5;
|
|
value_6 = text_tools_TextContains(value, piece);
|
|
}
|
|
value_4 = !value_6;
|
|
}
|
|
if (value_4) {
|
|
int64_t slash = text_tools_TextFindLast(resolved, StringLiteral("/"));
|
|
if (slash > 0LL) {
|
|
String directory = compiler_backend_cache_Owned(StringRange(resolved, (int64_t)0LL, (int64_t)slash));
|
|
String* value_8 = &((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).parent);
|
|
(*value_8) = directory;
|
|
}
|
|
}
|
|
compiler_backend_cache_Release(resolved);
|
|
}
|
|
int64_t value_9 = (int64_t)((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).parent).length;
|
|
bool value_10 = value_9 == 0LL;
|
|
bool value_11 = value_10;
|
|
if (!value_11) {
|
|
bool value_12 = compiler_backend_cache_AppendOwned(&(parents), (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).parent);
|
|
value_11 = !value_12;
|
|
}
|
|
if (value_11) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
}
|
|
for (int64_t it_index = 0LL; it_index < pending.count; it_index++) {
|
|
String dependency = ZIRAN_VEC_INDEX((pending).data, (pending).count, it_index);
|
|
if (!ok) {
|
|
break;
|
|
}
|
|
int64_t item = compiler_backend_cache_FileFind(cache, dependency, false);
|
|
bool value_13 = item < 0LL;
|
|
if (!value_13) {
|
|
bool value_14 = compiler_backend_cache_SpellingKey(cache, &(hash), dependency, &(parents), &(recordable));
|
|
value_13 = !value_14;
|
|
}
|
|
if (value_13) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
{
|
|
int64_t range_first_37 = 0LL;
|
|
int64_t range_last_37 = (int64_t)((uint64_t)(((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).probes).count) - UINT64_C(1));
|
|
int64_t probe_index = range_first_37;
|
|
if (probe_index <= range_last_37) for (;;) {
|
|
String probe = ZIRAN_VEC_INDEX(((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).probes).data, ((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).probes).count, probe_index);
|
|
bool value_15 = compiler_backend_cache_SpellingKey(cache, &(hash), probe, &(parents), &(recordable));
|
|
if (!value_15) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
if (probe_index == range_last_37) {
|
|
break;
|
|
}
|
|
probe_index = (int64_t)((uint64_t)probe_index + UINT64_C(1));
|
|
}
|
|
}
|
|
}
|
|
__type_c53c2d7c4913dc02 value_16 = pending;
|
|
pending = (*(dependencies));
|
|
(*(dependencies)) = value_16;
|
|
compiler_backend_cache_ClearNames(&(parents));
|
|
if (ok) {
|
|
compiler_backend_cache_HashFinish(&(hash), output);
|
|
}
|
|
bool value_17 = ok && (!recording || recordable);
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_17;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_ReadDependencies(String object, __type_c53c2d7c4913dc02* dependencies)
|
|
{
|
|
String path = compiler_backend_cache_JoinTemporary(object, StringLiteral(".d"));
|
|
if ((int64_t)(path).length == 0LL) {
|
|
return false;
|
|
}
|
|
__type_838711075b90279a bytes = {0};
|
|
__type_838711075b90279a* value_0 = &bytes;
|
|
bool value_1 = file_ReadFileInto(path, &(bytes));
|
|
if (!value_1) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool cleanup_return_0 = false;
|
|
{
|
|
compiler_backend_cache_Release(path);
|
|
}
|
|
bool value_2 = cleanup_return_0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_2;
|
|
}
|
|
Slice value_3 = {(bytes).data, (bytes).count};
|
|
Slice value_4 = SliceRange(value_3, 0LL, bytes.count, sizeof(*(bytes).data));
|
|
String text = StringView((const char *)(value_4).data, (size_t)(value_4).length);
|
|
int64_t colon = text_tools_TextFind(text, StringLiteral(":"), 0LL);
|
|
if (colon < 0LL) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool cleanup_return_1 = false;
|
|
{
|
|
compiler_backend_cache_Release(path);
|
|
}
|
|
bool value_5 = cleanup_return_1;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_5;
|
|
}
|
|
int64_t at = (int64_t)((uint64_t)colon + UINT64_C(1));
|
|
__type_838711075b90279a word = {0};
|
|
__type_838711075b90279a* value_6 = &word;
|
|
bool ok = true;
|
|
while (at <= (int64_t)(text).length) {
|
|
uint8_t value_7 = 0;
|
|
if (at < (int64_t)(text).length) {
|
|
value_7 = (uint8_t)ZIRAN_INDEX(text.data, text.length, at);
|
|
} else {
|
|
value_7 = 32;
|
|
}
|
|
uint8_t byte = value_7;
|
|
if (byte == 92 && (int64_t)((uint64_t)at + UINT64_C(1)) < (int64_t)(text).length) {
|
|
uint8_t next = (uint8_t)ZIRAN_INDEX(text.data, text.length, ((int64_t)((uint64_t)at + UINT64_C(1))));
|
|
if (next == 10) {
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
continue;
|
|
}
|
|
if (next == 32 || next == 9 || next == 35 || next == 92) {
|
|
uint8_t value_8 = next;
|
|
bool value_9 = false;
|
|
void *value_10 = ZirVecGrow((void *)(word).data, &(word).capacity, (word).count, sizeof(*(word).data));
|
|
if (value_10 != NULL) {
|
|
(word).data = (uint8_t *)value_10;
|
|
(word).data[(word).count++] = value_8;
|
|
value_9 = true;
|
|
}
|
|
if (!value_9) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
continue;
|
|
}
|
|
} else if (byte == 36) {
|
|
if ((int64_t)((uint64_t)at + UINT64_C(1)) >= (int64_t)(text).length || (uint8_t)ZIRAN_INDEX(text.data, text.length, ((int64_t)((uint64_t)at + UINT64_C(1)))) != 36) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
uint8_t value_11 = byte;
|
|
bool value_12 = false;
|
|
void *value_13 = ZirVecGrow((void *)(word).data, &(word).capacity, (word).count, sizeof(*(word).data));
|
|
if (value_13 != NULL) {
|
|
(word).data = (uint8_t *)value_13;
|
|
(word).data[(word).count++] = value_11;
|
|
value_12 = true;
|
|
}
|
|
if (!value_12) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(2));
|
|
continue;
|
|
}
|
|
if (text_tools_TextIsSpace(byte)) {
|
|
if (word.count > 0LL) {
|
|
Slice value_14 = {(word).data, (word).count};
|
|
Slice value_15 = SliceRange(value_14, 0LL, word.count, sizeof(*(word).data));
|
|
String owned = compiler_backend_cache_Owned(StringView((const char *)(value_15).data, (size_t)(value_15).length));
|
|
if ((int64_t)(owned).length == 0LL) {
|
|
ok = false;
|
|
} else {
|
|
String value_16 = owned;
|
|
bool value_17 = false;
|
|
void *value_18 = ZirVecGrow((void *)((*(dependencies))).data, &((*(dependencies))).capacity, ((*(dependencies))).count, sizeof(*((*(dependencies))).data));
|
|
if (value_18 != NULL) {
|
|
((*(dependencies))).data = (String *)value_18;
|
|
((*(dependencies))).data[((*(dependencies))).count++] = value_16;
|
|
value_17 = true;
|
|
}
|
|
if (!value_17) {
|
|
compiler_backend_cache_Release(owned);
|
|
ok = false;
|
|
}
|
|
}
|
|
if (!ok) {
|
|
break;
|
|
}
|
|
word.count = 0;
|
|
}
|
|
if (byte == 10) {
|
|
break;
|
|
}
|
|
} else {
|
|
uint8_t value_19 = byte;
|
|
bool value_20 = false;
|
|
void *value_21 = ZirVecGrow((void *)(word).data, &(word).capacity, (word).count, sizeof(*(word).data));
|
|
if (value_21 != NULL) {
|
|
(word).data = (uint8_t *)value_21;
|
|
(word).data[(word).count++] = value_19;
|
|
value_20 = true;
|
|
}
|
|
if (!value_20) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
}
|
|
at = (int64_t)((uint64_t)at + UINT64_C(1));
|
|
}
|
|
free((word).data);
|
|
(word).data = NULL;
|
|
word.capacity = 0;
|
|
word.count = 0;
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool value_22 = ok;
|
|
if (value_22) {
|
|
int64_t value_23 = dependencies->count;
|
|
value_22 = (value_23 > 0LL);
|
|
}
|
|
bool cleanup_return_2 = value_22;
|
|
{
|
|
compiler_backend_cache_Release(path);
|
|
}
|
|
bool value_24 = cleanup_return_2;
|
|
free((*value_6).data);
|
|
(*value_6).data = NULL;
|
|
(*value_6).capacity = 0;
|
|
(*value_6).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_24;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_ReadInteger(Slice bytes, int64_t* offset, uint32_t* output)
|
|
{
|
|
int64_t value_0 = (int64_t)((uint64_t)(*(offset)) + UINT64_C(4));
|
|
int64_t value_1 = (int64_t)(bytes).length;
|
|
if (value_0 > value_1) {
|
|
return false;
|
|
}
|
|
uint32_t value = 0;
|
|
for (int64_t index = 0LL; index <= 3LL; index++) {
|
|
uint8_t value_2 = ((uint8_t *)bytes.data)[SliceIndex(bytes, (int64_t)((int64_t)((uint64_t)(*(offset)) + (uint64_t)index)))];
|
|
uint32_t value_3 = ZiShl32((uint32_t)(value_2), (uint64_t)((uint32_t)(((int64_t)(UINT64_C(8) * (uint64_t)index)))), 32);
|
|
value = (uint32_t)((uint32_t)value | (uint32_t)value_3);
|
|
}
|
|
int64_t* value_4 = &((*(offset)));
|
|
(*value_4) = (int64_t)((uint64_t)((*value_4)) + UINT64_C(4));
|
|
uint32_t* value_5 = &((*(output)));
|
|
(*value_5) = value;
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_ReadDigest(Slice bytes, int64_t* offset, Digest* output)
|
|
{
|
|
int64_t value_0 = (int64_t)((uint64_t)(*(offset)) + UINT64_C(32));
|
|
int64_t value_1 = (int64_t)(bytes).length;
|
|
if (value_0 > value_1) {
|
|
return false;
|
|
}
|
|
for (int64_t index = 0LL; index <= 31LL; index++) {
|
|
uint8_t* value_2 = &(output->bytes[index]);
|
|
uint8_t value_3 = ((uint8_t *)bytes.data)[SliceIndex(bytes, (int64_t)((int64_t)((uint64_t)(*(offset)) + (uint64_t)index)))];
|
|
(*value_2) = value_3;
|
|
}
|
|
int64_t* value_4 = &((*(offset)));
|
|
(*value_4) = (int64_t)((uint64_t)((*value_4)) + UINT64_C(32));
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_SameDigest(Digest left, Digest right)
|
|
{
|
|
for (int64_t index = 0LL; index <= 31LL; index++) {
|
|
if ((left.bytes)[index] != (right.bytes)[index]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_Piped(BuildCache* cache)
|
|
{
|
|
return cache != ((void *)0) && cache->piped;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_Hit(BuildCache* cache, String object)
|
|
{
|
|
if (cache == ((void *)0)) {
|
|
return false;
|
|
}
|
|
String path = compiler_backend_cache_JoinTemporary(object, StringLiteral(".inputs"));
|
|
if ((int64_t)(path).length == 0LL) {
|
|
return false;
|
|
}
|
|
__type_838711075b90279a bytes = {0};
|
|
__type_838711075b90279a* value_0 = &bytes;
|
|
bool value_1 = file_ReadFileInto(path, &(bytes));
|
|
if (!value_1) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool cleanup_return_0 = false;
|
|
{
|
|
compiler_backend_cache_Release(path);
|
|
}
|
|
bool value_2 = cleanup_return_0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_2;
|
|
}
|
|
Slice value_3 = {(bytes).data, (bytes).count};
|
|
Slice value_4 = SliceRange(value_3, 0LL, bytes.count, sizeof(*(bytes).data));
|
|
String data = StringView((const char *)(value_4).data, (size_t)(value_4).length);
|
|
int64_t at = 0LL;
|
|
if ((int64_t)(data).length < 16LL || !StringEqual(StringRange(data, (int64_t)0LL, (int64_t)16LL), StringLiteral("Ziran C cache 1\n"))) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool cleanup_return_1 = false;
|
|
{
|
|
compiler_backend_cache_Release(path);
|
|
}
|
|
bool value_5 = cleanup_return_1;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_5;
|
|
}
|
|
at = 16LL;
|
|
Digest identity = {0};
|
|
Digest object_digest = {0};
|
|
Digest lookup = {0};
|
|
uint32_t count = 0;
|
|
Slice value_6 = {(bytes).data, (bytes).count};
|
|
bool value_7 = compiler_backend_cache_ReadDigest(SliceRange(value_6, 0LL, bytes.count, sizeof(*(bytes).data)), &(at), &(identity));
|
|
bool value_8 = value_7;
|
|
if (value_8) {
|
|
Slice value_9 = {(bytes).data, (bytes).count};
|
|
bool value_10 = compiler_backend_cache_ReadDigest(SliceRange(value_9, 0LL, bytes.count, sizeof(*(bytes).data)), &(at), &(object_digest));
|
|
value_8 = value_10;
|
|
}
|
|
bool value_11 = value_8;
|
|
if (value_11) {
|
|
Slice value_12 = {(bytes).data, (bytes).count};
|
|
bool value_13 = compiler_backend_cache_ReadDigest(SliceRange(value_12, 0LL, bytes.count, sizeof(*(bytes).data)), &(at), &(lookup));
|
|
value_11 = value_13;
|
|
}
|
|
bool value_14 = value_11;
|
|
if (value_14) {
|
|
Slice value_15 = {(bytes).data, (bytes).count};
|
|
bool value_16 = compiler_backend_cache_ReadInteger(SliceRange(value_15, 0LL, bytes.count, sizeof(*(bytes).data)), &(at), &(count));
|
|
value_14 = value_16;
|
|
}
|
|
bool ok = value_14 && count > 0 && count <= 16384;
|
|
if (ok) {
|
|
ok = compiler_backend_cache_SameDigest(identity, cache->identity);
|
|
}
|
|
__type_c53c2d7c4913dc02 dependencies = {0};
|
|
__type_c53c2d7c4913dc02* value_17 = &dependencies;
|
|
if (ok) {
|
|
int64_t compiled = compiler_backend_cache_FileDigest(cache, object);
|
|
bool value_18 = compiled < 0LL;
|
|
if (!value_18) {
|
|
bool value_19 = compiler_backend_cache_SameDigest((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, compiled)).digest, object_digest);
|
|
value_18 = !value_19;
|
|
}
|
|
if (value_18) {
|
|
ok = false;
|
|
}
|
|
}
|
|
{
|
|
int64_t range_first_42 = 0LL;
|
|
int64_t range_last_42 = (int64_t)((uint64_t)(count) - UINT64_C(1));
|
|
int64_t index = range_first_42;
|
|
if (index <= range_last_42) for (;;) {
|
|
if (!ok) {
|
|
break;
|
|
}
|
|
uint32_t length = 0;
|
|
Slice value_20 = {(bytes).data, (bytes).count};
|
|
bool value_21 = compiler_backend_cache_ReadInteger(SliceRange(value_20, 0LL, bytes.count, sizeof(*(bytes).data)), &(at), &(length));
|
|
if (!value_21 || length == 0 || (int64_t)((uint64_t)at + (uint64_t)(length)) > (int64_t)(data).length) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
String dependency = StringRange(data, (int64_t)at, (int64_t)((int64_t)((uint64_t)at + (uint64_t)(length))));
|
|
at = (int64_t)((uint64_t)at + (uint64_t)(length));
|
|
Digest saved = {0};
|
|
String value_22 = StringLiteral("\000");
|
|
bool value_23 = false;
|
|
{
|
|
String value = dependency;
|
|
String piece = value_22;
|
|
value_23 = text_tools_TextContains(value, piece);
|
|
}
|
|
bool value_25 = value_23;
|
|
if (!value_25) {
|
|
Slice value_26 = {(bytes).data, (bytes).count};
|
|
bool value_27 = compiler_backend_cache_ReadDigest(SliceRange(value_26, 0LL, bytes.count, sizeof(*(bytes).data)), &(at), &(saved));
|
|
value_25 = !value_27;
|
|
}
|
|
if (value_25) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
int64_t item = compiler_backend_cache_FileDigest(cache, dependency);
|
|
bool value_28 = item < 0LL || (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).unsafe;
|
|
bool value_29 = value_28;
|
|
if (!value_29) {
|
|
bool value_30 = compiler_backend_cache_SameDigest((ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).digest, saved);
|
|
value_29 = !value_30;
|
|
}
|
|
bool value_31 = value_29;
|
|
bool value_32 = value_31;
|
|
if (!value_32) {
|
|
bool value_33 = compiler_backend_cache_AppendOwned(&(dependencies), dependency);
|
|
value_32 = !value_33;
|
|
}
|
|
if (value_32) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
if (index == range_last_42) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
if (ok) {
|
|
Digest current = {0};
|
|
bool value_34 = at == (int64_t)(data).length;
|
|
bool value_35 = value_34 && compiler_backend_cache_LookupDigest(cache, &(dependencies), &(current), false);
|
|
bool value_36 = value_35;
|
|
ok = value_36 && compiler_backend_cache_SameDigest(current, lookup);
|
|
}
|
|
compiler_backend_cache_ClearNames(&(dependencies));
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
bool cleanup_return_2 = ok;
|
|
{
|
|
compiler_backend_cache_Release(path);
|
|
}
|
|
bool value_37 = cleanup_return_2;
|
|
free((*value_17).data);
|
|
(*value_17).data = NULL;
|
|
(*value_17).capacity = 0;
|
|
(*value_17).count = 0;
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_37;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_AppendBytes(__type_838711075b90279a* output, Slice bytes)
|
|
{
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(bytes).length; it_index++) {
|
|
uint8_t byte = ((uint8_t *)bytes.data)[it_index];
|
|
uint8_t value_0 = byte;
|
|
bool value_1 = false;
|
|
void *value_2 = ZirVecGrow((void *)((*(output))).data, &((*(output))).capacity, ((*(output))).count, sizeof(*((*(output))).data));
|
|
if (value_2 != NULL) {
|
|
((*(output))).data = (uint8_t *)value_2;
|
|
((*(output))).data[((*(output))).count++] = value_0;
|
|
value_1 = true;
|
|
}
|
|
if (!value_1) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_AppendText(__type_838711075b90279a* output, String value)
|
|
{
|
|
for (int64_t it_index = 0LL; it_index < (int64_t)(value).length; it_index++) {
|
|
uint8_t byte = (uint8_t)value.data[it_index];
|
|
uint8_t value_0 = byte;
|
|
bool value_1 = false;
|
|
void *value_2 = ZirVecGrow((void *)((*(output))).data, &((*(output))).capacity, ((*(output))).count, sizeof(*((*(output))).data));
|
|
if (value_2 != NULL) {
|
|
((*(output))).data = (uint8_t *)value_2;
|
|
((*(output))).data[((*(output))).count++] = value_0;
|
|
value_1 = true;
|
|
}
|
|
if (!value_1) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_AppendDigest(__type_838711075b90279a* output, Digest value)
|
|
{
|
|
Slice value_0 = {value.bytes, 32};
|
|
return compiler_backend_cache_AppendBytes(output, value_0);
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_AppendCount(__type_838711075b90279a* output, uint32_t value)
|
|
{
|
|
uint8_t bytes[4];
|
|
for (int64_t index = 0LL; index <= 3LL; index++) {
|
|
uint8_t* value_0 = &(bytes[index]);
|
|
uint8_t value_1 = (uint8_t)((ZiShrU32(value, (uint64_t)((uint32_t)(((int64_t)(UINT64_C(8) * (uint64_t)index)))), 32)));
|
|
(*value_0) = value_1;
|
|
}
|
|
Slice value_2 = {bytes, 4};
|
|
return compiler_backend_cache_AppendBytes(output, value_2);
|
|
}
|
|
|
|
bool
|
|
compiler_backend_cache_AppendNumber(__type_838711075b90279a* output, int64_t value)
|
|
{
|
|
if (value == 0LL) {
|
|
uint8_t value_0 = 48;
|
|
bool value_1 = false;
|
|
void *value_2 = ZirVecGrow((void *)((*(output))).data, &((*(output))).capacity, ((*(output))).count, sizeof(*((*(output))).data));
|
|
if (value_2 != NULL) {
|
|
((*(output))).data = (uint8_t *)value_2;
|
|
((*(output))).data[((*(output))).count++] = value_0;
|
|
value_1 = true;
|
|
}
|
|
return value_1;
|
|
}
|
|
uint8_t digits[24] = {0};
|
|
int64_t at = 24LL;
|
|
int64_t positive = value;
|
|
while (positive > 0LL) {
|
|
at = (int64_t)((uint64_t)at - UINT64_C(1));
|
|
uint8_t* value_3 = &(ZIRAN_INDEX(digits, sizeof(digits) / sizeof(digits[0]), at));
|
|
(*value_3) = (uint8_t)(((int64_t)(UINT64_C(48) + (uint64_t)((positive % 10LL)))));
|
|
positive = positive / 10LL;
|
|
}
|
|
Slice value_4 = {digits, 24};
|
|
return compiler_backend_cache_AppendBytes(output, SliceRange(value_4, (int64_t)at, (int64_t)24LL, sizeof(uint8_t)));
|
|
}
|
|
|
|
String
|
|
compiler_backend_cache_TemporaryInputPath(String object, int64_t attempt)
|
|
{
|
|
__type_838711075b90279a bytes = {0};
|
|
__type_838711075b90279a* value_0 = &bytes;
|
|
bool value_1 = compiler_backend_cache_AppendText(&(bytes), object);
|
|
bool value_2 = !value_1;
|
|
if (!value_2) {
|
|
bool value_3 = compiler_backend_cache_AppendText(&(bytes), StringLiteral(".inputs."));
|
|
value_2 = !value_3;
|
|
}
|
|
bool value_4 = value_2;
|
|
if (!value_4) {
|
|
bool value_5 = compiler_backend_cache_AppendNumber(&(bytes), attempt);
|
|
value_4 = !value_5;
|
|
}
|
|
if (value_4) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
String value_6 = StringLiteral("");
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_6;
|
|
}
|
|
Slice value_7 = {(bytes).data, (bytes).count};
|
|
Slice value_8 = SliceRange(value_7, 0LL, bytes.count, sizeof(*(bytes).data));
|
|
String value_9 = vec_TextDetach(vec_TextCopy(StringView((const char *)(value_8).data, (size_t)(value_8).length)));
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
return value_9;
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_Record(BuildCache* cache, String object, String source)
|
|
{
|
|
bool value_0 = cache == ((void *)0) || (int64_t)(object).length == 0LL || (int64_t)(object).length >= 4096LL || (int64_t)(source).length == 0LL;
|
|
if (value_0 || (int64_t)(source).length >= 4096LL) {
|
|
return;
|
|
}
|
|
__type_c53c2d7c4913dc02 dependencies = {0};
|
|
__type_c53c2d7c4913dc02* value_1 = &dependencies;
|
|
bool value_2 = compiler_backend_cache_ReadDependencies(object, &(dependencies));
|
|
if (!value_2) {
|
|
compiler_backend_cache_ClearNames(&(dependencies));
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return;
|
|
}
|
|
bool source_present = false;
|
|
bool ok = dependencies.count > 0LL && dependencies.count <= 16384LL;
|
|
{
|
|
int64_t range_first_10 = 0LL;
|
|
int64_t range_last_10 = (int64_t)((uint64_t)(dependencies.count) - UINT64_C(1));
|
|
int64_t index = range_first_10;
|
|
if (index <= range_last_10) for (;;) {
|
|
if (!ok) {
|
|
break;
|
|
}
|
|
int64_t value_3 = (int64_t)(ZIRAN_VEC_INDEX((dependencies).data, (dependencies).count, index)).length;
|
|
bool value_4 = value_3 == 0LL;
|
|
if (!value_4) {
|
|
int64_t value_5 = (int64_t)(ZIRAN_VEC_INDEX((dependencies).data, (dependencies).count, index)).length;
|
|
value_4 = (value_5 >= 4096LL);
|
|
}
|
|
if (value_4) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
if (StringEqual(ZIRAN_VEC_INDEX((dependencies).data, (dependencies).count, index), source)) {
|
|
source_present = true;
|
|
}
|
|
int64_t item = compiler_backend_cache_FileDigest(cache, ZIRAN_VEC_INDEX((dependencies).data, (dependencies).count, index));
|
|
bool value_6 = item < 0LL || (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).unsafe;
|
|
bool value_7 = value_6;
|
|
if (!value_7) {
|
|
BuildCache* value_8 = cache;
|
|
PathInfo value_9 = (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).info;
|
|
bool value_10 = false;
|
|
{
|
|
BuildCache* cache = value_8;
|
|
PathInfo info = value_9;
|
|
bool changed = false;
|
|
int64_t value_12 = 0;
|
|
if (changed) {
|
|
value_12 = info.changed;
|
|
} else {
|
|
value_12 = info.modified;
|
|
}
|
|
int64_t seconds = value_12;
|
|
uint32_t value_13 = 0;
|
|
if (changed) {
|
|
value_13 = info.changed_nanoseconds;
|
|
} else {
|
|
value_13 = info.modified_nanoseconds;
|
|
}
|
|
uint32_t nanoseconds = value_13;
|
|
int64_t value_14 = cache->started_seconds;
|
|
if (seconds != value_14) {
|
|
int64_t value_15 = cache->started_seconds;
|
|
value_10 = seconds < value_15;
|
|
goto value_11;
|
|
}
|
|
int64_t value_16 = (int64_t)(nanoseconds);
|
|
int64_t value_17 = cache->started_nanoseconds;
|
|
value_10 = value_16 < value_17;
|
|
value_11: ;
|
|
}
|
|
value_7 = !value_10;
|
|
}
|
|
bool value_18 = value_7;
|
|
bool value_19 = value_18;
|
|
if (!value_19) {
|
|
BuildCache* value_20 = cache;
|
|
PathInfo value_21 = (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).info;
|
|
bool value_22 = false;
|
|
{
|
|
BuildCache* cache = value_20;
|
|
PathInfo info = value_21;
|
|
bool changed = true;
|
|
int64_t value_24 = 0;
|
|
if (changed) {
|
|
value_24 = info.changed;
|
|
} else {
|
|
value_24 = info.modified;
|
|
}
|
|
int64_t seconds = value_24;
|
|
uint32_t value_25 = 0;
|
|
if (changed) {
|
|
value_25 = info.changed_nanoseconds;
|
|
} else {
|
|
value_25 = info.modified_nanoseconds;
|
|
}
|
|
uint32_t nanoseconds = value_25;
|
|
int64_t value_26 = cache->started_seconds;
|
|
if (seconds != value_26) {
|
|
int64_t value_27 = cache->started_seconds;
|
|
value_22 = seconds < value_27;
|
|
goto value_23;
|
|
}
|
|
int64_t value_28 = (int64_t)(nanoseconds);
|
|
int64_t value_29 = cache->started_nanoseconds;
|
|
value_22 = value_28 < value_29;
|
|
value_23: ;
|
|
}
|
|
value_19 = !value_22;
|
|
}
|
|
if (value_19) {
|
|
ok = false;
|
|
break;
|
|
}
|
|
if (index == range_last_10) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
Digest lookup = {0};
|
|
if (ok && source_present) {
|
|
ok = compiler_backend_cache_LookupDigest(cache, &(dependencies), &(lookup), true);
|
|
} else {
|
|
ok = false;
|
|
}
|
|
int64_t value_30 = 0;
|
|
if (ok) {
|
|
int64_t value_31 = compiler_backend_cache_FileDigest(cache, object);
|
|
value_30 = value_31;
|
|
} else {
|
|
value_30 = -1LL;
|
|
}
|
|
int64_t compiled = value_30;
|
|
if (compiled < 0LL) {
|
|
ok = false;
|
|
}
|
|
if (!ok) {
|
|
compiler_backend_cache_ClearNames(&(dependencies));
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return;
|
|
}
|
|
__type_838711075b90279a bytes = {0};
|
|
__type_838711075b90279a* value_32 = &bytes;
|
|
bool value_33 = compiler_backend_cache_AppendText(&(bytes), StringLiteral("Ziran C cache 1\n"));
|
|
bool value_34 = !value_33;
|
|
if (!value_34) {
|
|
bool value_35 = compiler_backend_cache_AppendDigest(&(bytes), cache->identity);
|
|
value_34 = !value_35;
|
|
}
|
|
bool value_36 = value_34;
|
|
if (!value_36) {
|
|
bool value_37 = compiler_backend_cache_AppendDigest(&(bytes), (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, compiled)).digest);
|
|
value_36 = !value_37;
|
|
}
|
|
bool value_38 = value_36;
|
|
if (!value_38) {
|
|
bool value_39 = compiler_backend_cache_AppendDigest(&(bytes), lookup);
|
|
value_38 = !value_39;
|
|
}
|
|
bool value_40 = value_38;
|
|
if (!value_40) {
|
|
bool value_41 = compiler_backend_cache_AppendCount(&(bytes), (uint32_t)(dependencies.count));
|
|
value_40 = !value_41;
|
|
}
|
|
if (value_40) {
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
compiler_backend_cache_ClearNames(&(dependencies));
|
|
free((*value_32).data);
|
|
(*value_32).data = NULL;
|
|
(*value_32).capacity = 0;
|
|
(*value_32).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
return;
|
|
}
|
|
{
|
|
int64_t range_first_48 = 0LL;
|
|
int64_t range_last_48 = (int64_t)((uint64_t)(dependencies.count) - UINT64_C(1));
|
|
int64_t index = range_first_48;
|
|
if (index <= range_last_48) for (;;) {
|
|
if (!ok) {
|
|
break;
|
|
}
|
|
int64_t item = compiler_backend_cache_FileDigest(cache, ZIRAN_VEC_INDEX((dependencies).data, (dependencies).count, index));
|
|
bool value_42 = item < 0LL || (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).unsafe;
|
|
bool value_43 = value_42;
|
|
if (!value_43) {
|
|
BuildCache* value_44 = cache;
|
|
PathInfo value_45 = (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).info;
|
|
bool value_46 = false;
|
|
{
|
|
BuildCache* cache = value_44;
|
|
PathInfo info = value_45;
|
|
bool changed = false;
|
|
int64_t value_48 = 0;
|
|
if (changed) {
|
|
value_48 = info.changed;
|
|
} else {
|
|
value_48 = info.modified;
|
|
}
|
|
int64_t seconds = value_48;
|
|
uint32_t value_49 = 0;
|
|
if (changed) {
|
|
value_49 = info.changed_nanoseconds;
|
|
} else {
|
|
value_49 = info.modified_nanoseconds;
|
|
}
|
|
uint32_t nanoseconds = value_49;
|
|
int64_t value_50 = cache->started_seconds;
|
|
if (seconds != value_50) {
|
|
int64_t value_51 = cache->started_seconds;
|
|
value_46 = seconds < value_51;
|
|
goto value_47;
|
|
}
|
|
int64_t value_52 = (int64_t)(nanoseconds);
|
|
int64_t value_53 = cache->started_nanoseconds;
|
|
value_46 = value_52 < value_53;
|
|
value_47: ;
|
|
}
|
|
value_43 = !value_46;
|
|
}
|
|
bool value_54 = value_43;
|
|
bool value_55 = value_54;
|
|
if (!value_55) {
|
|
BuildCache* value_56 = cache;
|
|
PathInfo value_57 = (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).info;
|
|
bool value_58 = false;
|
|
{
|
|
BuildCache* cache = value_56;
|
|
PathInfo info = value_57;
|
|
bool changed = true;
|
|
int64_t value_60 = 0;
|
|
if (changed) {
|
|
value_60 = info.changed;
|
|
} else {
|
|
value_60 = info.modified;
|
|
}
|
|
int64_t seconds = value_60;
|
|
uint32_t value_61 = 0;
|
|
if (changed) {
|
|
value_61 = info.changed_nanoseconds;
|
|
} else {
|
|
value_61 = info.modified_nanoseconds;
|
|
}
|
|
uint32_t nanoseconds = value_61;
|
|
int64_t value_62 = cache->started_seconds;
|
|
if (seconds != value_62) {
|
|
int64_t value_63 = cache->started_seconds;
|
|
value_58 = seconds < value_63;
|
|
goto value_59;
|
|
}
|
|
int64_t value_64 = (int64_t)(nanoseconds);
|
|
int64_t value_65 = cache->started_nanoseconds;
|
|
value_58 = value_64 < value_65;
|
|
value_59: ;
|
|
}
|
|
value_55 = !value_58;
|
|
}
|
|
bool value_66 = value_55;
|
|
bool value_67 = value_66;
|
|
if (!value_67) {
|
|
bool value_68 = compiler_backend_cache_AppendCount(&(bytes), (uint32_t)((int64_t)(ZIRAN_VEC_INDEX((dependencies).data, (dependencies).count, index)).length));
|
|
value_67 = !value_68;
|
|
}
|
|
bool value_69 = value_67;
|
|
bool value_70 = value_69;
|
|
if (!value_70) {
|
|
bool value_71 = compiler_backend_cache_AppendText(&(bytes), ZIRAN_VEC_INDEX((dependencies).data, (dependencies).count, index));
|
|
value_70 = !value_71;
|
|
}
|
|
bool value_72 = value_70;
|
|
bool value_73 = value_72;
|
|
if (!value_73) {
|
|
bool value_74 = compiler_backend_cache_AppendDigest(&(bytes), (ZIRAN_VEC_INDEX((cache->files).data, (cache->files).count, item)).digest);
|
|
value_73 = !value_74;
|
|
}
|
|
if (value_73) {
|
|
ok = false;
|
|
}
|
|
if (index == range_last_48) {
|
|
break;
|
|
}
|
|
index = (int64_t)((uint64_t)index + UINT64_C(1));
|
|
}
|
|
}
|
|
if (ok) {
|
|
int64_t attempt = 0LL;
|
|
String temporary = StringLiteral("");
|
|
FileHandle file = {0};
|
|
while (attempt < 128LL) {
|
|
attempt = (int64_t)((uint64_t)attempt + UINT64_C(1));
|
|
int32_t value_75 = (int32_t)((uint32_t)(zir_f_36a3c20ab8e249b6_OwnProcessId()) * 128u);
|
|
temporary = compiler_backend_cache_TemporaryInputPath(object, (int64_t)((uint64_t)(value_75) + (uint64_t)attempt));
|
|
if ((int64_t)(temporary).length == 0LL) {
|
|
break;
|
|
}
|
|
file = OpenExclusivePrivate(temporary);
|
|
if (file.valid) {
|
|
break;
|
|
}
|
|
compiler_backend_cache_Release(temporary);
|
|
temporary = StringLiteral("");
|
|
}
|
|
if ((int64_t)(temporary).length > 0LL && file.valid) {
|
|
Slice value_76 = {(bytes).data, (bytes).count};
|
|
int64_t written = WriteAt(file, SliceRange(value_76, 0LL, bytes.count, sizeof(*(bytes).data)), 0LL);
|
|
bool value_77 = SyncFile(file);
|
|
bool closed = value_77 && CloseFile(file);
|
|
if (written == bytes.count && closed) {
|
|
String final = compiler_backend_cache_JoinTemporary(object, StringLiteral(".inputs"));
|
|
if ((int64_t)(final).length > 0LL) {
|
|
ok = RenamePath(temporary, final);
|
|
compiler_backend_cache_Release(final);
|
|
}
|
|
}
|
|
if (!ok) {
|
|
RemoveFile(temporary);
|
|
}
|
|
compiler_backend_cache_Release(temporary);
|
|
}
|
|
}
|
|
free((bytes).data);
|
|
(bytes).data = NULL;
|
|
bytes.capacity = 0;
|
|
bytes.count = 0;
|
|
compiler_backend_cache_ClearNames(&(dependencies));
|
|
free((*value_32).data);
|
|
(*value_32).data = NULL;
|
|
(*value_32).capacity = 0;
|
|
(*value_32).count = 0;
|
|
free((*value_1).data);
|
|
(*value_1).data = NULL;
|
|
(*value_1).capacity = 0;
|
|
(*value_1).count = 0;
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_ReleaseFingerprints(__type_d5737c4838766181* values)
|
|
{
|
|
__type_d5737c4838766181 owned = {0};
|
|
__type_d5737c4838766181* value_0 = &owned;
|
|
__type_d5737c4838766181 value_1 = owned;
|
|
owned = (*(values));
|
|
(*(values)) = value_1;
|
|
{
|
|
int64_t it_index = 0LL;
|
|
while (it_index < owned.count) {
|
|
Fingerprint* it = &(ZIRAN_VEC_INDEX((owned).data, (owned).count, it_index));
|
|
compiler_backend_cache_Release(it->path);
|
|
compiler_backend_cache_Release(it->parent);
|
|
compiler_backend_cache_ClearNames(&(it->probes));
|
|
it_index = (int64_t)((uint64_t)it_index + UINT64_C(1));
|
|
}
|
|
}
|
|
__type_d5737c4838766181 value_2 = owned;
|
|
owned = (*(values));
|
|
(*(values)) = value_2;
|
|
for (int64_t value_3 = 0; value_3 < ((*(values))).count; ++value_3) {
|
|
for (size_t value_4 = 0; value_4 < sizeof(((((*(values))).data[value_3]).digest).bytes) / sizeof((((((*(values))).data[value_3]).digest).bytes)[0]); ++value_4) {
|
|
}
|
|
free((((*(values))).data[value_3]).probes.data);
|
|
(((*(values))).data[value_3]).probes.data = NULL;
|
|
(((*(values))).data[value_3]).probes.capacity = 0;
|
|
(((*(values))).data[value_3]).probes.count = 0;
|
|
}
|
|
free(((*(values))).data);
|
|
((*(values))).data = NULL;
|
|
(*(values)).capacity = 0;
|
|
(*(values)).count = 0;
|
|
for (int64_t value_5 = 0; value_5 < ((*value_0)).count; ++value_5) {
|
|
for (size_t value_6 = 0; value_6 < sizeof(((((*value_0)).data[value_5]).digest).bytes) / sizeof((((((*value_0)).data[value_5]).digest).bytes)[0]); ++value_6) {
|
|
}
|
|
free((((*value_0)).data[value_5]).probes.data);
|
|
(((*value_0)).data[value_5]).probes.data = NULL;
|
|
(((*value_0)).data[value_5]).probes.capacity = 0;
|
|
(((*value_0)).data[value_5]).probes.count = 0;
|
|
}
|
|
free((*value_0).data);
|
|
(*value_0).data = NULL;
|
|
(*value_0).capacity = 0;
|
|
(*value_0).count = 0;
|
|
}
|
|
|
|
void
|
|
compiler_backend_cache_Close(BuildCache* cache)
|
|
{
|
|
if (cache == ((void *)0)) {
|
|
return;
|
|
}
|
|
compiler_backend_cache_ClearNames(&(cache->roots));
|
|
free((cache->roots).data);
|
|
(cache->roots).data = NULL;
|
|
cache->roots.capacity = 0;
|
|
cache->roots.count = 0;
|
|
compiler_backend_cache_Release(cache->output);
|
|
compiler_backend_cache_Release(cache->executable);
|
|
compiler_backend_cache_ReleaseFingerprints(&(cache->files));
|
|
compiler_backend_cache_ReleaseFingerprints(&(cache->candidates));
|
|
zir_f_36a3c20ab8e249b6_FreeOwned((void*)(cache));
|
|
}
|