Skip to content

Commit

Permalink
Merge pull request #256 from dosemu2/gcc
Browse files Browse the repository at this point in the history
Gcc
  • Loading branch information
stsp authored Jan 2, 2025
2 parents 90bdf22 + 381da74 commit 74d5adb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
23 changes: 18 additions & 5 deletions fdpp/clang.mak
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ else
$(error binutils-x86-64-linux-gnu not installed)
endif
endif
# don't use ?= here as that doesn't override make's builtin CC var
CC = clang
CXX = clang++
CLANG_VER := $(shell $(CXX) -v 2>&1 | head -n 1 | \
CLANG_VER := $(shell $(CXX) --version 2>&1 | head -n 1 | grep clang | \
sed -E 's/.+ version ([^.]+)\.[^.]+\.[^ ]+.*/\1/')
ifeq ($(CLANG_VER),)
# its gcc, set to 16 as it had buggy packed diagnostic, similar to gcc
CLANG_VER := 16
GCC_VER := $(shell $(CXX) --version 2>&1 | head -n 1 | grep GCC | \
sed -E 's/.+ \(GCC\) ([^.]+)\.[^.]+\.[^ ]+.*/\1/')
ifeq ($(GCC_VER),)
$(error unknown compiler)
endif
endif
FLEX = $(shell which flex 2>/dev/null)
ifneq ($(FLEX),)
LEX = $(FLEX)
Expand All @@ -40,7 +46,9 @@ export PKG_CONFIG
TARGETOPT = -std=c++20 -c -fno-threadsafe-statics -fpic \
-DCLANG_VER=$(CLANG_VER)
# _XTRA should go at the end of cmd line
ifeq ($(GCC_VER),)
TARGETOPT_XTRA = -Wno-format-invalid-specifier -Wno-c99-designator
endif

DEBUG_MODE ?= 1
EXTRA_DEBUG ?= 0
Expand All @@ -50,10 +58,15 @@ USE_UBSAN ?= 0

IFLAGS = -iquote $(srcdir)/../hdr
CPPFLAGS += $(IFLAGS) -DFDPP
WFLAGS = -Wall -Werror=packed-non-pod -Wno-unknown-warning-option
ifeq ($(GCC_VER),)
WFLAGS := -Wall -Werror=packed-non-pod -Wno-unknown-warning-option
ifneq ($(CLANG_VER),16)
WFLAGS += -Wpacked
endif
else
WFLAGS := -Wno-attributes
endif
WFLAGS += -Wno-address-of-packed-member
WCFLAGS = $(WFLAGS)
ifeq ($(DEBUG_MODE),1)
DBGFLAGS += -ggdb3
Expand Down
12 changes: 6 additions & 6 deletions fdpp/farptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class FarPtrBase {
uint16_t off() const { return ptr.off; }
uint32_t get_fp32() const { return ((ptr.seg << 16) | ptr.off); }
far_s get_far() const { return ptr; }
far_s& get_ref() { return ptr; }
far_s *get_ref() { return &ptr; }
T* get_ptr() const { return (T*)resolve_segoff(ptr); }
void *get_buf() const { return (void*)resolve_segoff(ptr); }
explicit operator uint32_t () const { return get_fp32(); }
Expand Down Expand Up @@ -508,7 +508,7 @@ class AsmSym {
/* everyone with get_ref() method should have no copy ctor */
AsmSym() = default;
AsmSym(const AsmSym<T> &) = delete;
far_s* get_ref() { return &sym.get_ref(); }
far_s* get_ref() { return sym.get_ref(); }
};

template<typename T>
Expand All @@ -521,7 +521,7 @@ class AsmFSym {

AsmFSym() = default;
AsmFSym(const AsmFSym<T> &) = delete;
far_s* get_ref() { return &sym.get_ref(); }
far_s* get_ref() { return sym.get_ref(); }
};

class CallSym {
Expand Down Expand Up @@ -582,7 +582,7 @@ class ArSymBase {
return sym[idx];
}

far_s* get_ref() { return &sym.get_ref(); }
far_s* get_ref() { return sym.get_ref(); }
};

template<typename T, typename P, auto M, int O = 0>
Expand Down Expand Up @@ -672,7 +672,7 @@ class AsmFarPtr {

AsmFarPtr() = default;
AsmFarPtr(const AsmFarPtr<T> &) = delete;
far_s* get_ref() { return &ptr.get_ref(); }
far_s* get_ref() { return ptr.get_ref(); }
};

template<typename T, uint16_t (*SEG)(void)>
Expand All @@ -685,7 +685,7 @@ class AsmNearPtr {

AsmNearPtr() = default;
AsmNearPtr(const AsmNearPtr<T, SEG> &) = delete;
far_s* get_ref() { return &ptr.get_ref(); }
far_s* get_ref() { return ptr.get_ref(); }
};

template<typename T, typename P, auto M, int O = 0>
Expand Down
4 changes: 2 additions & 2 deletions fdpp/thunks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ void FdppLoaderHook(uint16_t seg, int (*getsymoff)(void *, const char *),
int off = getsymoff(arg, asm_cthunks[i].name);
assert(off != -1);
assert(asm_cthunks[i].name);
asm_tab[i].seg = seg;
asm_tab[i].off = off;
asm_tab[asm_cthunks[i].num].seg = seg;
asm_tab[asm_cthunks[i].num].off = off;
}

f.off = getsymoff(arg, "near_wrp");
Expand Down
6 changes: 3 additions & 3 deletions fdpp/thunks_a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ struct athunk asm_thunks[] = {

const int num_athunks = _countof(asm_thunks);

struct athunk asm_cthunks[] = {
#define ASMCSYM(s, n) [n] = { _S(_##s), NULL, 0 },
struct cthunk asm_cthunks[] = {
#define ASMCSYM(s, n) { _S(_##s), n, NULL },
#include "plt_asmc.h"
#define ASMPSYM(s, n) [n] = { _S(s), NULL, 0 },
#define ASMPSYM(s, n) { _S(s), n, NULL },
#include "plt_asmp.h"
};

Expand Down
8 changes: 7 additions & 1 deletion fdpp/thunks_a.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ struct athunk {
unsigned flags;
};

struct cthunk {
const char *name;
int num;
struct far_s *ptr;
};

extern struct athunk asm_thunks[];
extern const int num_athunks;
extern struct athunk asm_cthunks[];
extern struct cthunk asm_cthunks[];
extern const int num_cthunks;
extern far_t asm_tab[];

0 comments on commit 74d5adb

Please sign in to comment.