Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"llvmlibc": {
"ENABLE_CXX_LIBS": "ON",
"ENABLE_LIBC_TESTS": "OFF",
"ENABLE_LIBC_TESTS": "ON",
"ENABLE_COMPILER_RT_TESTS": "OFF",
"ENABLE_LIBCXX_TESTS": "OFF"
}
Expand Down
7 changes: 6 additions & 1 deletion arm-software/embedded/arm-runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,12 @@ endif()
###############################################################################

if(C_LIBRARY STREQUAL llvmlibc)
set(test_cmd "qemu-system-arm -M ${QEMU_MACHINE} -semihosting -nographic -device loader$<COMMA>file=@BINARY@")
set(test_cmd
"qemu-system-arm -M ${QEMU_MACHINE} -cpu ${QEMU_CPU} ${QEMU_PARAMS} \
-chardev stdio$<COMMA>mux=on$<COMMA>id=stdio0 \
-semihosting-config enable=on$<COMMA>chardev=stdio0$<COMMA>arg=program-name \
-monitor none -serial none -nographic -device loader$<COMMA>file=@BINARY@$<COMMA>cpu-num=0")

set(lib_compile_flags "${lib_compile_flags} -Wno-error=atomic-alignment")

set(common_llvmlibc_cmake_args
Expand Down
20 changes: 11 additions & 9 deletions arm-software/embedded/llvmlibc-support/crt0/exceptions_7a.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ EXFN_ATTR void handle_fiq() {
// bytes long, and contains code. The whole table must be 32-byte aligned.
// The table may also be relocated, so we make it position-independent by
// having a table of handler addresses and loading the address to pc.
__attribute__((naked, section(".vectors"), aligned(32))) void vector_table() {
[[gnu::section(".vectors"), gnu::aligned(32), gnu::used, gnu::naked,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change in syntax here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly most of the code should use this [[c++11]] type syntax. It's more modern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this is C++ syntax then, not C.

I'm not against it, but we must be sure that this will be compatible with all configurations, especially with a C-only compilation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this attribute syntax has been backported, at least on Clang. Also, this library is compiled on our systems, and this attribute will not affect user code at all, so as long as we don't use very old versions that are unsupported by Clang, we should be OK.

https://stackoverflow.com/questions/74574618/old-style-vs-c11-attribute-syntax

gnu::target("arm")]]
void vector_table() {
asm("LDR pc, [pc, #24]");
asm("LDR pc, [pc, #24]");
asm("LDR pc, [pc, #24]");
Expand All @@ -104,14 +106,14 @@ __attribute__((naked, section(".vectors"), aligned(32))) void vector_table() {
asm("LDR pc, [pc, #24]");
asm("LDR pc, [pc, #24]");
asm("LDR pc, [pc, #24]");
asm(".word %0" : : "X"(handle_reset));
asm(".word %0" : : "X"(handle_undefined));
asm(".word %0" : : "X"(handle_svc_hyp_smc));
asm(".word %0" : : "X"(handle_prefetch_abort));
asm(".word %0" : : "X"(handle_data_abort));
asm(".word %0" : : "X"(handle_hyp_trap));
asm(".word %0" : : "X"(handle_irq));
asm(".word %0" : : "X"(handle_fiq));
asm(".word %c0" : : "X"(handle_reset));
asm(".word %c0" : : "X"(handle_undefined));
asm(".word %c0" : : "X"(handle_svc_hyp_smc));
asm(".word %c0" : : "X"(handle_prefetch_abort));
asm(".word %c0" : : "X"(handle_data_abort));
asm(".word %c0" : : "X"(handle_hyp_trap));
asm(".word %c0" : : "X"(handle_irq));
asm(".word %c0" : : "X"(handle_fiq));
}

} // namespace exceptions
Expand Down
8 changes: 6 additions & 2 deletions arm-software/embedded/llvmlibc-support/crt0/exceptions_a.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ void setup() {
// The vector table is always at address 0. The inline assembly is needed
// here to hide the memcpy to a null pointer from the compiler.
void *final_vector_table = NULL;
asm("" : "+r"(final_vector_table));
memcpy(final_vector_table, (void *)&vector_table, 64);
// Don't use memcpy as llvmlibc memcpy will fault a copy to address 0.
// Size is more important than speed here so don't unroll the loop.
_Pragma("clang loop unroll(disable) vectorize(disable)") for (
Comment on lines +39 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, memcpy itself has unrolled loops, so I think you shouldn't worry about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to prevent an internal LLVM-libc issue (see line 38)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean the pragma to prevent loop unrolling. Since even memcpy itself uses unrolling, having this pragma here is unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see what you mean. Here I'm removing the call to memcpy and using a manual copy.

int i = 0; i < 64 / sizeof(unsigned int); i++) {
((unsigned int *)final_vector_table)[i] = ((unsigned int *)vector_table)[i];
}
#endif
}

Expand Down