Skip to content

Commit 4006419

Browse files
mrexodiaPigrecos
andcommitted
Fix compilation on Windows (clang-cl)
Partially based on lifting-bits#678 Co-authored-by: Max <[email protected]>
1 parent 7dd5170 commit 4006419

File tree

8 files changed

+35
-39
lines changed

8 files changed

+35
-39
lines changed

bin/differential_tester_x86/LiftAndCompare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class DifferentialModuleBuilder {
168168
};
169169

170170
using random_bytes_engine =
171-
std::independent_bits_engine<std::default_random_engine, CHAR_BIT, uint8_t>;
171+
std::independent_bits_engine<std::default_random_engine, CHAR_BIT, uint16_t>;
172172

173173

174174
std::string PrintState(X86State *state) {

cxx-common/superbuild.cmake

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,6 @@ if(ninja_EXECUTABLE STREQUAL "ninja_EXECUTABLE-NOTFOUND")
4040
endif()
4141
message(STATUS "Ninja: ${ninja_EXECUTABLE}")
4242

43-
# On macOS, search Homebrew for keg-only versions of Bison and Flex. Xcode does
44-
# not provide new enough versions for us to use.
45-
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
46-
execute_process(
47-
COMMAND brew --prefix bison
48-
RESULT_VARIABLE BREW_BISON
49-
OUTPUT_VARIABLE BREW_BISON_PREFIX
50-
OUTPUT_STRIP_TRAILING_WHITESPACE
51-
)
52-
if(BREW_BISON EQUAL 0 AND EXISTS "${BREW_BISON_PREFIX}")
53-
message(STATUS "Found Bison keg installed by Homebrew at ${BREW_BISON_PREFIX}")
54-
set(BISON_EXECUTABLE "${BREW_BISON_PREFIX}/bin/bison")
55-
else()
56-
message(FATAL_ERROR "Bison not found, to install: brew install bison")
57-
endif()
58-
59-
execute_process(
60-
COMMAND brew --prefix flex
61-
RESULT_VARIABLE BREW_FLEX
62-
OUTPUT_VARIABLE BREW_FLEX_PREFIX
63-
OUTPUT_STRIP_TRAILING_WHITESPACE
64-
)
65-
if(BREW_FLEX EQUAL 0 AND EXISTS "${BREW_FLEX_PREFIX}")
66-
message(STATUS "Found Flex keg installed by Homebrew at ${BREW_FLEX_PREFIX}")
67-
set(FLEX_EXECUTABLE "${BREW_FLEX_PREFIX}/bin/flex")
68-
else()
69-
message(FATAL_ERROR "Flex not found, to install: brew install flex")
70-
endif()
71-
else()
72-
message(STATUS "Looking for flex/bison")
73-
find_package(FLEX 2.6 REQUIRED)
74-
find_package(BISON 2.6 REQUIRED)
75-
endif()
76-
7743
# Documentation: https://cmake.org/cmake/help/latest/module/ExternalProject.html
7844
include(ExternalProject)
7945

include/remill/Arch/Context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <functional>
2424
#include <map>
2525
#include <string_view>
26+
#include <string>
2627

2728
namespace remill {
2829

include/remill/Arch/Runtime/Math.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static_assert(8 == sizeof(float128_t), "Invalid `float128_t` size.");
3636
// A "native_float80_t" is a native type that is closes to approximating
3737
// an x86 80-bit float.
3838
// when building against CUDA, default to 64-bit float80s
39-
#if !defined(__CUDACC__) && (defined(__x86_64__) || defined(__i386__) || defined(_M_X86))
39+
#if !defined(__CUDACC__) && !defined(_WIN32) && (defined(__x86_64__) || defined(__i386__) || defined(_M_X86))
4040
#if defined(__float80)
4141
typedef __float80 native_float80_t;
4242
#else
@@ -53,7 +53,7 @@ union union_ld {
5353
struct {
5454
uint8_t data[kEightyBitsInBytes];
5555
// when building against CUDA, default to 64-bit float80s
56-
#if !defined(__CUDACC__) && (defined(__x86_64__) || defined(__i386__) || defined(_M_X86))
56+
#if !defined(__CUDACC__) && !defined(_WIN32) && (defined(__x86_64__) || defined(__i386__) || defined(_M_X86))
5757
// We are doing x86 on x86, so we have native x86 FP80s, but they
5858
// are not available in raw 80-bit native form.
5959
//
@@ -154,8 +154,11 @@ union nan80_t {
154154
} __attribute__((packed));
155155
} __attribute__((packed));
156156

157+
// TODO: this should be fixed
158+
#ifndef _WIN32
157159
static_assert(sizeof(float80_t) == sizeof(nan80_t),
158160
"Invalid packing of `nan80_t`.");
161+
#endif // _WIN32
159162

160163
#if __has_include(<cmath>)
161164
# include <cmath>

include/remill/BC/InstructionLifter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <cstdint>
2020
#include <memory>
2121
#include <string_view>
22+
#include <string>
2223

2324
namespace llvm {
2425
class Argument;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 5cef084ec56ee326d3b169c2c83950a017ae02f6 Mon Sep 17 00:00:00 2001
2+
From: Duncan Ogilvie <[email protected]>
3+
Date: Wed, 29 Oct 2025 00:52:58 +0100
4+
Subject: [PATCH] Fix narrowing conversion warning
5+
6+
error : constant expression evaluates to -1 which cannot be narrowed to type 'uintb' (aka 'unsigned long long') [-Wc++11-narrowing]
7+
---
8+
Ghidra/Features/Decompiler/src/decompile/cpp/address.cc | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
12+
index 9e8039d486e..a939961c371 100644
13+
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
14+
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/address.cc
15+
@@ -630,8 +630,8 @@ void RangeList::decode(Decoder &decoder)
16+
#ifdef UINTB4
17+
uintb uintbmasks[9] = { 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff };
18+
#else
19+
-uintb uintbmasks[9] = { 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffffLL,
20+
- 0xffffffffffffLL, 0xffffffffffffffLL, 0xffffffffffffffffLL };
21+
+uintb uintbmasks[9] = { 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffffULL,
22+
+ 0xffffffffffffULL, 0xffffffffffffffULL, 0xffffffffffffffffULL };
23+
#endif
24+
25+
/// Treat the given \b val as a constant of \b size bytes

test_runner_lib/TestRunner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ uint8_t MemoryHandler::read_byte(uint64_t addr) {
8686
return state.find(addr)->second;
8787
}
8888

89-
auto genned = rbe();
89+
auto genned = static_cast<uint8_t>(rbe());
9090
uninitialized_reads.insert({addr, genned});
9191
state.insert({addr, genned});
9292
return genned;

test_runner_lib/include/test_runner/TestRunner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace test_runner {
4545

4646

4747
using random_bytes_engine =
48-
std::independent_bits_engine<std::default_random_engine, CHAR_BIT, uint8_t>;
48+
std::independent_bits_engine<std::default_random_engine, CHAR_BIT, uint16_t>;
4949

5050

5151
class MemoryHandler {

0 commit comments

Comments
 (0)