Cleanup some arch defines and fix builds.

This commit is contained in:
Mike Pall 2020-06-15 11:23:04 +02:00
parent d333b1a6fe
commit 34e53736c6
8 changed files with 31 additions and 17 deletions

View File

@ -212,7 +212,7 @@ TARGET_CC= $(STATIC_CC)
TARGET_STCC= $(STATIC_CC) TARGET_STCC= $(STATIC_CC)
TARGET_DYNCC= $(DYNAMIC_CC) TARGET_DYNCC= $(DYNAMIC_CC)
TARGET_LD= $(CROSS)$(CC) TARGET_LD= $(CROSS)$(CC)
TARGET_AR= $(CROSS)ar rcus TARGET_AR= $(CROSS)ar rcus 2>/dev/null
TARGET_STRIP= $(CROSS)strip TARGET_STRIP= $(CROSS)strip
TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib) TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
@ -312,7 +312,6 @@ ifeq (Windows,$(TARGET_SYS))
TARGET_XSHLDFLAGS= -shared -Wl,--out-implib,$(TARGET_DLLDOTANAME) TARGET_XSHLDFLAGS= -shared -Wl,--out-implib,$(TARGET_DLLDOTANAME)
TARGET_DYNXLDOPTS= TARGET_DYNXLDOPTS=
else else
TARGET_AR+= 2>/dev/null
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1)) ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
TARGET_XCFLAGS+= -fno-stack-protector TARGET_XCFLAGS+= -fno-stack-protector
endif endif

View File

@ -302,7 +302,7 @@ static void *mmap_probe(size_t size)
#if LJ_ALLOC_MMAP32 #if LJ_ALLOC_MMAP32
#if defined(__sun__) #if LJ_TARGET_SOLARIS
#define LJ_ALLOC_MMAP32_START ((uintptr_t)0x1000) #define LJ_ALLOC_MMAP32_START ((uintptr_t)0x1000)
#else #else
#define LJ_ALLOC_MMAP32_START ((uintptr_t)0) #define LJ_ALLOC_MMAP32_START ((uintptr_t)0)

View File

@ -8,6 +8,8 @@
#include "lua.h" #include "lua.h"
/* -- Target definitions -------------------------------------------------- */
/* Target endianess. */ /* Target endianess. */
#define LUAJIT_LE 0 #define LUAJIT_LE 0
#define LUAJIT_BE 1 #define LUAJIT_BE 1
@ -38,6 +40,14 @@
#define LUAJIT_OS_BSD 4 #define LUAJIT_OS_BSD 4
#define LUAJIT_OS_POSIX 5 #define LUAJIT_OS_POSIX 5
/* Number mode. */
#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */
#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */
#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */
#define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */
/* -- Target detection ---------------------------------------------------- */
/* Select native target if no target defined. */ /* Select native target if no target defined. */
#ifndef LUAJIT_TARGET #ifndef LUAJIT_TARGET
@ -74,7 +84,10 @@
defined(__NetBSD__) || defined(__OpenBSD__) || \ defined(__NetBSD__) || defined(__OpenBSD__) || \
defined(__DragonFly__)) && !defined(__ORBIS__) defined(__DragonFly__)) && !defined(__ORBIS__)
#define LUAJIT_OS LUAJIT_OS_BSD #define LUAJIT_OS LUAJIT_OS_BSD
#elif (defined(__sun__) && defined(__svr4__)) || defined(__HAIKU__) #elif (defined(__sun__) && defined(__svr4__))
#define LJ_TARGET_SOLARIS 1
#define LUAJIT_OS LUAJIT_OS_POSIX
#elif defined(__HAIKU__)
#define LUAJIT_OS LUAJIT_OS_POSIX #define LUAJIT_OS LUAJIT_OS_POSIX
#elif defined(__CYGWIN__) #elif defined(__CYGWIN__)
#define LJ_TARGET_CYGWIN 1 #define LJ_TARGET_CYGWIN 1
@ -103,6 +116,7 @@
#define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS) #define LJ_TARGET_WINDOWS (LUAJIT_OS == LUAJIT_OS_WINDOWS)
#define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX) #define LJ_TARGET_LINUX (LUAJIT_OS == LUAJIT_OS_LINUX)
#define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX) #define LJ_TARGET_OSX (LUAJIT_OS == LUAJIT_OS_OSX)
#define LJ_TARGET_BSD (LUAJIT_OS == LUAJIT_OS_BSD)
#define LJ_TARGET_IOS (LJ_TARGET_OSX && (LUAJIT_TARGET == LUAJIT_ARCH_ARM || LUAJIT_TARGET == LUAJIT_ARCH_ARM64)) #define LJ_TARGET_IOS (LJ_TARGET_OSX && (LUAJIT_TARGET == LUAJIT_ARCH_ARM || LUAJIT_TARGET == LUAJIT_ARCH_ARM64))
#define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS) #define LJ_TARGET_POSIX (LUAJIT_OS > LUAJIT_OS_WINDOWS)
#define LJ_TARGET_DLOPEN LJ_TARGET_POSIX #define LJ_TARGET_DLOPEN LJ_TARGET_POSIX
@ -142,10 +156,7 @@
#endif #endif
#endif #endif
#define LJ_NUMMODE_SINGLE 0 /* Single-number mode only. */ /* -- Arch-specific settings ---------------------------------------------- */
#define LJ_NUMMODE_SINGLE_DUAL 1 /* Default to single-number mode. */
#define LJ_NUMMODE_DUAL 2 /* Dual-number mode only. */
#define LJ_NUMMODE_DUAL_SINGLE 3 /* Default to dual-number mode. */
/* Set target architecture properties. */ /* Set target architecture properties. */
#if LUAJIT_TARGET == LUAJIT_ARCH_X86 #if LUAJIT_TARGET == LUAJIT_ARCH_X86
@ -407,9 +418,7 @@
#error "No target architecture defined" #error "No target architecture defined"
#endif #endif
#ifndef LJ_PAGESIZE /* -- Checks for requirements --------------------------------------------- */
#define LJ_PAGESIZE 4096
#endif
/* Check for minimum required compiler versions. */ /* Check for minimum required compiler versions. */
#if defined(__GNUC__) #if defined(__GNUC__)
@ -485,6 +494,8 @@
#endif #endif
#endif #endif
/* -- Derived defines ----------------------------------------------------- */
/* Enable or disable the dual-number mode for the VM. */ /* Enable or disable the dual-number mode for the VM. */
#if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \ #if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \
(LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1) (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1)
@ -582,6 +593,10 @@
#define LJ_TARGET_UNALIGNED 0 #define LJ_TARGET_UNALIGNED 0
#endif #endif
#ifndef LJ_PAGESIZE
#define LJ_PAGESIZE 4096
#endif
/* Various workarounds for embedded operating systems or weak C runtimes. */ /* Various workarounds for embedded operating systems or weak C runtimes. */
#if defined(__ANDROID__) || defined(__symbian__) || LJ_TARGET_XBOX360 || LJ_TARGET_WINDOWS #if defined(__ANDROID__) || defined(__symbian__) || LJ_TARGET_XBOX360 || LJ_TARGET_WINDOWS
#define LUAJIT_NO_LOG2 #define LUAJIT_NO_LOG2

View File

@ -363,7 +363,7 @@ static const ELFheader elfhdr_template = {
.eosabi = 12, .eosabi = 12,
#elif defined(__DragonFly__) #elif defined(__DragonFly__)
.eosabi = 0, .eosabi = 0,
#elif (defined(__sun__) && defined(__svr4__)) #elif LJ_TARGET_SOLARIS
.eosabi = 6, .eosabi = 6,
#else #else
.eosabi = 0, .eosabi = 0,

View File

@ -27,12 +27,12 @@
@set DASMDIR=..\dynasm @set DASMDIR=..\dynasm
@set DASM=%DASMDIR%\dynasm.lua @set DASM=%DASMDIR%\dynasm.lua
@set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c @set ALL_LIB=lib_base.c lib_math.c lib_bit.c lib_string.c lib_table.c lib_io.c lib_os.c lib_package.c lib_debug.c lib_jit.c lib_ffi.c
@set GC64=-DLUAJIT_ENABLE_GC64 @set GC64=
@set DASC=vm_x64.dasc @set DASC=vm_x64.dasc
@if "%1" neq "gc32" goto :NOGC32 @if "%1" neq "gc32" goto :NOGC32
@shift @shift
@set GC64= @set GC64=-DLUAJIT_DISABLE_GC64
@set DASC=vm_x86.dasc @set DASC=vm_x86.dasc
:NOGC32 :NOGC32

View File

@ -4734,7 +4734,7 @@ static void emit_asm_debug(BuildCtx *ctx)
".LEFDE1:\n\n", (int)ctx->codesz - fcofs); ".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
#endif #endif
#if !LJ_NO_UNWIND #if !LJ_NO_UNWIND
#if (defined(__sun__) && defined(__svr4__)) #if LJ_TARGET_SOLARIS
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n");
#else #else
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");

View File

@ -5548,7 +5548,7 @@ static void emit_asm_debug(BuildCtx *ctx)
".LEFDE1:\n\n", (int)ctx->codesz - fcofs); ".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
#endif #endif
#if !LJ_NO_UNWIND #if !LJ_NO_UNWIND
#if (defined(__sun__) && defined(__svr4__)) #if LJ_TARGET_SOLARIS
#if LJ_64 #if LJ_64
fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n"); fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n");
#else #else

View File

@ -9,7 +9,7 @@
@setlocal @setlocal
@echo ---- Host compiler ---- @echo ---- Host compiler ----
@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /DLUAJIT_ENABLE_GC64 @set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
@set LJLINK=link /nologo @set LJLINK=link /nologo
@set LJMT=mt /nologo @set LJMT=mt /nologo
@set DASMDIR=..\dynasm @set DASMDIR=..\dynasm