Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clang/ARM support for MINIX #195

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Build MINIX/arm with clang

It is now possible to build a full minix distribution for BeaglBone White/Black and BeagleBoardxM using clang instead of GCC.

This also add support to run the Kuya tests on ARM, which was not possible when GCC was used, because of problems in the C++ exception handling.

## Known Bugs

The following tests still fails:
1. 53: Division by zero does not trigger exceptions
2. 75: ru.tv_secs can't be zero (and is zero)
3. 85: hangs
4. isofs: Fails because of an out of memory condition
5. vnd: crash
6. Running two times the kyua tests in a row, without rebooting in between will lead to a mostly failed second run because of copy-on-write errors.


3 changes: 3 additions & 0 deletions distrib/sets/lists/minix-comp/md.evbarm
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@
./usr/include/arm/vm.h minix-comp
./usr/include/arm/vmparam.h minix-comp
./usr/include/arm/wchar_limits.h minix-comp
./usr/include/clang-3.6/arm_acle.h minix-comp llvm,llvmcmds
./usr/include/clang-3.6/arm_neon.h minix-comp llvm,llvmcmds
./usr/include/clang-3.6/stdatomic.h minix-comp llvm,llvmcmds
./usr/include/evbarm minix-comp
./usr/include/evbarm/disklabel.h minix-comp
./usr/include/evbarm/intr.h minix-comp
Expand Down
1 change: 1 addition & 0 deletions external/bsd/llvm/dist/clang/lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,7 @@ class ARMTargetInfo : public TargetInfo {
SizeType = UnsignedInt;

switch (T.getOS()) {
case llvm::Triple::Minix:
case llvm::Triple::NetBSD:
WCharType = SignedInt;
break;
Expand Down
2 changes: 1 addition & 1 deletion external/bsd/llvm/dist/clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args,
// FIXME: Thumb should just be another -target-feaure, not in the triple.
#if defined(__minix) || 1
// Minix/ARM-specific force to ARMv7 and EABI.
StringRef Suffix = "v7";
StringRef Suffix = "v7a";
Triple.setEnvironment(llvm::Triple::EABI);
#else
StringRef Suffix = Triple.isOSBinFormatMachO()
Expand Down
12 changes: 12 additions & 0 deletions external/bsd/llvm/dist/clang/lib/Driver/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,10 @@ StringRef tools::arm::getARMFloatABI(const Driver &D, const ArgList &Args,
}
break;

case llvm::Triple::Minix:
FloatABI = "softfp";
break;

default:
switch(Triple.getEnvironment()) {
case llvm::Triple::GNUEABIHF:
Expand Down Expand Up @@ -796,6 +800,9 @@ void Clang::AddARMTargetArgs(const ArgList &Args,
ABIName = "aapcs";
break;
default:
if (Triple.getOS() == llvm::Triple::Minix)
ABIName = "apcs-gnu";

if (Triple.getOS() == llvm::Triple::NetBSD)
ABIName = "apcs-gnu";
else
Expand Down Expand Up @@ -7733,6 +7740,11 @@ void minix::Link::ConstructJob(Compilation &C, const JobAction &JA,
// Many NetBSD architectures support more than one ABI.
// Determine the correct emulation for ld.
switch (getToolChain().getArch()) {
case llvm::Triple::arm:
case llvm::Triple::thumb:
CmdArgs.push_back("-m");
CmdArgs.push_back("armelf_minix");
break;
case llvm::Triple::x86:
CmdArgs.push_back("-m");
CmdArgs.push_back("elf_i386_minix");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,8 @@ llvm::Optional<ProgramStateRef> MallocChecker::performKernelMalloc(
if (!KernelZeroFlagVal.hasValue()) {
if (OS == llvm::Triple::FreeBSD)
KernelZeroFlagVal = 0x0100;
else if (OS == llvm::Triple::Minix)
KernelZeroFlagVal = 0x0002;
else if (OS == llvm::Triple::NetBSD)
KernelZeroFlagVal = 0x0002;
else if (OS == llvm::Triple::OpenBSD)
Expand Down
2 changes: 2 additions & 0 deletions external/bsd/llvm/dist/llvm/lib/Support/Triple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,8 @@ const char *Triple::getARMCPUForArch(StringRef MArch) const {
// supported by LLVM.
// FIXME: Should warn once that we're falling back.
switch (getOS()) {
case llvm::Triple::Minix:
return "cortex-a8";
case llvm::Triple::NetBSD:
switch (getEnvironment()) {
case llvm::Triple::GNUEABIHF:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo(StringRef TT) {

// Exceptions handling
switch (TheTriple.getOS()) {
case Triple::Minix:
case Triple::NetBSD:
ExceptionsType = ExceptionHandling::DwarfCFI;
break;
Expand Down
5 changes: 0 additions & 5 deletions minix/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ PROG= kernel
BINDIR= /usr/sbin
MAN=

.if ${MACHINE_ARCH} == "earm" && ${MKLLVM:Uno} == "yes"
# BJG - problems with optimisation of the kernel by llvm
DBG=-O0
.endif

.include "arch/${MACHINE_ARCH}/Makefile.inc"

SRCS+= clock.c cpulocals.c interrupt.c main.c proc.c system.c \
Expand Down
25 changes: 23 additions & 2 deletions minix/kernel/arch/earm/arch_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <machine/vm.h>
#include <machine/signal.h>
#include <arm/armreg.h>
#include <arm/vfpreg.h>

#include <minix/u64.h>

Expand All @@ -26,16 +27,36 @@

void * k_stacks;


#define VFP_COPROC 10
#define VFP_COPROC2 11
void fpu_init(void)
{
const char *model = NULL;
uint32_t cpu_media_and_vfp_features[2];

const uint32_t cpacr_vfp = CPACR_CPn(VFP_COPROC);
const uint32_t cpacr_vfp2 = CPACR_CPn(VFP_COPROC2);

/*
* We first need to enable access to the coprocessors.
*/
uint32_t cpacr = armreg_cpacr_read();
cpacr |= __SHIFTIN(CPACR_ALL, cpacr_vfp);
cpacr |= __SHIFTIN(CPACR_ALL, cpacr_vfp2);
armreg_cpacr_write(cpacr);

isb();

/* Enable vfp/neon unit */
armreg_fpexc_write(VFP_FPEXC_EN);
}

void save_local_fpu(struct proc *pr, int retain)
{
}

void save_fpu(struct proc *pr)
void
save_fpu(struct proc *pr)
{
}

Expand Down
4 changes: 0 additions & 4 deletions minix/servers/vm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ SRCS= main.c alloc.c utility.c exit.c fork.c break.c \
mem_anon.c mem_directphys.c mem_anon_contig.c mem_shared.c \
mem_cache.c cache.c vfs.c mem_file.c fdref.c acl.c

.if ${MACHINE_ARCH} == "earm"
LDFLAGS+= -T ${.CURDIR}/arch/${MACHINE_ARCH}/vm.lds
.endif

.if ${MKPAE:Uno} != "no"
CPPFLAGS+= -DPAE=1
.endif
Expand Down
Loading