build/cross-tools: explicitly set ISA for riscv64

* Enable TLS for riscv64. For now select a dummy
  implementation.
* RISC-V has a register (tp) dedicated to TLS
* All the "desktop-like" RV64 chipsets implement GC
* Same ISA we currently build for... but calls it out
  in-case defaults change.

Change-Id: I623b6e5c309b6a6e80ec378e456b2335c561269d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3632
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Alexander von Gluck IV 2021-01-15 08:51:17 -06:00 committed by Alex von Gluck IV
parent 5ec64c5cdd
commit d123849688
3 changed files with 32 additions and 22 deletions

View File

@ -41,6 +41,7 @@ rule ArchitectureSetup architecture
case ppc : archFlags += -mcpu=440fp ;
case arm : archFlags += -march=armv7-a -mfloat-abi=hard ;
case x86 : archFlags += -march=pentium ;
case riscv64 : archFlags += -march=rv64gc ;
}
if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 {
# TODO: These should be included in Clang's compiler specs.

View File

@ -62,13 +62,13 @@ arm-*)
gdbTarget="arm-unknown-elf"
;;
riscv*-*)
binutilsConfigureArgs="--disable-multilib"
gccConfigureArgs="--disable-multilib"
gdbConfigureArgs="--disable-multilib"
binutilsConfigureArgs=" --with-arch=rv64gc"
gccConfigureArgs=" --with-arch=rv64gc"
gdbConfigureArgs=""
# TODO: Disable building with TLS support for riscv until implemented.
binutilsConfigureArgs="$binutilsConfigureArgs --disable-tls"
gccConfigureArgs="$gccConfigureArgs --disable-tls"
binutilsConfigureArgs="$binutilsConfigureArgs --disable-multilib"
gccConfigureArgs="$gccConfigureArgs --disable-multilib"
gdbConfigureArgs="$gdbConfigureArgs --disable-multilib"
;;
powerpc-*)
binutilsConfigureArgs="--disable-multilib"

View File

@ -1,24 +1,25 @@
/*
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the MIT License.
*/
* Copyright 2019 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
// ToDo: this is a dummy implementation - I've not yet gained enough knowledge
// to decide how this should be done, so it's just broken now (okay for single
// threaded apps, though).
// we don't want to have the inline assembly included here
#ifndef _NO_INLINE_ASM
# define _NO_INLINE_ASM 1
#endif
#include <runtime_loader/runtime_loader.h>
#include "support/TLS.h"
#include "tls.h"
static int32 gNextSlot = TLS_FIRST_FREE_SLOT;
static void *gSlots[TLS_MAX_KEYS];
struct tls_index {
unsigned long ti_module;
unsigned long ti_offset;
};
void* __tls_get_addr(struct tls_index* ti);
static int32 gNextSlot = TLS_FIRST_FREE_SLOT;
// TODO: RISCV64 has a dedicated (TP) register for TLS
int32
tls_allocate(void)
@ -34,20 +35,28 @@ tls_allocate(void)
void *
tls_get(int32 index)
{
return gSlots[index];
debugger("Implement TLS support before SMP");
return NULL;
}
void **
tls_address(int32 index)
{
return &gSlots[index];
debugger("Implement TLS support before SMP");
return NULL;
}
void
tls_set(int32 index, void *value)
{
gSlots[index] = value;
debugger("Implement TLS support before SMP");
}
void*
__tls_get_addr(struct tls_index* ti)
{
return __gRuntimeLoader->get_tls_address(ti->ti_module, ti->ti_offset);
}