Skip to content

Commit

Permalink
Use own assembler on RISC-V
Browse files Browse the repository at this point in the history
Continue using system linker, though.
  • Loading branch information
tyfkda committed Apr 27, 2024
1 parent 3f3c304 commit f09f099
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@
//

#if XCC_TARGET_ARCH == XCC_ARCH_AARCH64
# define AS_USE_CC
# define USE_SYS_AS
# define USE_SYS_LD
# if XCC_TARGET_PLATFORM != XCC_PLATFORM_APPLE
# define NO_STD_LIB
# endif

#elif XCC_TARGET_ARCH != XCC_ARCH_X64 && XCC_TARGET_ARCH != XCC_ARCH_WASM
# define AS_USE_CC
# define USE_SYS_LD
#endif

#define USE_ALLOCA
Expand Down
20 changes: 12 additions & 8 deletions src/xcc/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,20 +549,24 @@ int main(int argc, char *argv[]) {
const char *prefix = get_exe_prefix(xccpath);
char *cpp_path = join_exe_prefix(xccpath, prefix, "cpp");
char *cc1_path = join_exe_prefix(xccpath, prefix, "cc1");
#if !defined(AS_USE_CC)
char *as_path = join_exe_prefix(xccpath, prefix, "as");
char *ld_path = join_exe_prefix(xccpath, prefix, "ld");
#elif defined(HOST_CC_PREFIX)
#define S(x) S2(x)
#define S2(x) #x
#if !defined(USE_SYS_AS)
char *as_path = join_exe_prefix(xccpath, prefix, "as");
#elif defined(HOST_CC_PREFIX)
char *as_path = S(HOST_CC_PREFIX) "as";
char *ld_path = S(HOST_CC_PREFIX) "gcc";
#undef S2
#undef S
#else
char *as_path = "/usr/bin/as";
#endif
#if !defined(USE_SYS_LD)
char *ld_path = join_exe_prefix(xccpath, prefix, "ld");
#elif defined(HOST_CC_PREFIX)
char *ld_path = S(HOST_CC_PREFIX) "gcc";
#else
char *ld_path = "/usr/bin/cc";
#endif
#undef S2
#undef S

Vector *cpp_cmd = new_vector();
vec_push(cpp_cmd, cpp_path);
Expand Down Expand Up @@ -635,7 +639,7 @@ int main(int argc, char *argv[]) {
}

if (opts.out_type >= OutExecutable && !opts.use_ld) {
#if !defined(AS_USE_CC) || defined(NO_STD_LIB)
#if !defined(USE_SYS_LD) || defined(NO_STD_LIB)
if (!opts.nostdlib)
vec_push(opts.sources, JOIN_PATHS(root, "lib/crt0.a"));
if (!opts.nodefaultlibs && !opts.nostdlib)
Expand Down

0 comments on commit f09f099

Please sign in to comment.