Skip to content
This repository was archived by the owner on Jun 16, 2019. It is now read-only.

Commit d9c549c

Browse files
committed
Fix build on Linux
1 parent 8d8697a commit d9c549c

File tree

9 files changed

+15
-26
lines changed

9 files changed

+15
-26
lines changed

Makefile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# This Makefile has been tested on Ubuntu 16.10. Use at your own risk
22
# on anything else! (Or fix it and submit a PR.)
33

4-
CAPSTONE_DIR = /usr/include/capstone
54
LLVM_VERSION_SUFFIX = -3.9
65
PYTHON_INCLUDES = /usr/include/python2.7
76
PYTHON27 = python
@@ -21,7 +20,7 @@ CC = $(CLANGC)
2120
CXX = $(CLANG)
2221

2322
DIRECTORIES = $(sort $(dir $(wildcard $(CURDIR)/fcd/*/)))
24-
INCLUDES = $(DIRECTORIES:%=-I%) -isystem $(BUILD_DIR)/includes -isystem $(CAPSTONE_DIR)
23+
INCLUDES = $(DIRECTORIES:%=-I%) -isystem $(BUILD_DIR)/includes
2524
LLVM_CXXFLAGS = $(subst -I,-isystem ,$(shell $(LLVM_CONFIG) --cxxflags))
2625
LLVM_LIBS = $(shell $(LLVM_CONFIG) --libs $(LLVM_LIB_LIST))
2726
LLVM_LDFLAGS = $(shell $(LLVM_CONFIG) --ldflags)
@@ -33,7 +32,6 @@ CXXFLAGS = $(LLVM_CXXFLAGS) $(INCLUDES) $(CLANG_WARNINGS:%=-W%) --std=gnu++14
3332
CLANG_LIBS = -lclang $(addprefix $(shell $(LLVM_CONFIG) --libdir), $(addprefix "/libclang",$(addsuffix ".a",$(CLANG_LIB_LIST))))
3433

3534
export BUILD_DIR
36-
export CAPSTONE_DIR
3735
export CXX
3836
export CLANG
3937
export CXXFLAGS
@@ -60,11 +58,11 @@ $(BUILD_DIR)/bindings.cpp: fcd/python/bindings.py
6058
$(BUILD_DIR)/systemIncludePaths.cpp: $(BUILD_DIR)
6159
$(CXX) -E -x c++ -v - < /dev/null 2>&1 | sed -n '/#include <...>/,/End of search/p' > $(@:%.cpp=%.txt)
6260
echo 'const char* defaultHeaderSearchPathList[] = {' > $@
63-
cat $(@:%.cpp=%.txt) | grep -v '(framework directory)$$' | sed -n 's/^ \(.*\)/\t"\1",/p' >> $@
61+
grep -v '(framework directory)$$' $(@:%.cpp=%.txt) | sed -n 's/^ \(.*\)/\t"\1",/p' >> $@
6462
echo '\t0' >> $@
6563
echo '};' >> $@
6664
echo 'const char* defaultFrameworkSearchPathList[] = {' >> $@
67-
cat $(@:%.cpp=%.txt) | sed -n 's/^ \(.*\) (framework directory)/\t"\1",/p' >> $@
65+
sed -n 's/^ \(.*\) (framework directory)/\t"\1",/p' $(@:%.cpp=%.txt) >> $@
6866
echo '\t0' >> $@
6967
echo '};' >> $@
7068

Makefile.sub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o)
44
products: $(OBJECTS)
55

66
$(BUILD_DIR)/%.emulator.o: %.emulator.cpp
7-
$(CLANG) -c -emit-llvm --std=gnu++14 -isystem $(CAPSTONE_DIR) -O3 -o $(@:%.o=%.bc) $<
7+
$(CLANG) -c -emit-llvm --std=gnu++14 -O3 -o $(@:%.o=%.bc) $<
88
sed -e "s/{CPU}/$(<:%.emulator.cpp=%)/" $(INCBIN_TEMPLATE) > $(@:%.o=%.s)
99
cd $(BUILD_DIR) && $(CXX) -c -o $@ $(@:%.o=%.s)
1010

fcd.xcodeproj/project.pbxproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,7 @@
908908
GCC_DYNAMIC_NO_PIC = NO;
909909
GCC_NO_COMMON_BLOCKS = YES;
910910
GCC_OPTIMIZATION_LEVEL = 0;
911-
GCC_PREPROCESSOR_DEFINITIONS = (
912-
"DEBUG=1",
913-
"$(inherited)",
914-
);
911+
GCC_PREPROCESSOR_DEFINITIONS = "FCD_DEBUG=1";
915912
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
916913
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
917914
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
@@ -963,6 +960,7 @@
963960
ENABLE_STRICT_OBJC_MSGSEND = YES;
964961
GCC_C_LANGUAGE_STANDARD = gnu99;
965962
GCC_NO_COMMON_BLOCKS = YES;
963+
GCC_PREPROCESSOR_DEFINITIONS = "";
966964
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
967965
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
968966
GCC_WARN_UNDECLARED_SELECTOR = YES;
@@ -1062,7 +1060,8 @@
10621060
GCC_PREPROCESSOR_DEFINITIONS = (
10631061
"DEBUG=1",
10641062
"$(inherited)",
1065-
"__STDC_CONSTANT_MACROS\n__STDC_LIMIT_MACROS",
1063+
__STDC_CONSTANT_MACROS,
1064+
__STDC_LIMIT_MACROS,
10661065
);
10671066
GCC_VERSION = "";
10681067
HEADER_SEARCH_PATHS = (

fcd/ast/pre_ast_cfg.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ void PreAstContext::generateBlocks(Function& fn)
160160
Expression* caseCondition = nullptr;
161161
if (dest == bb || defaultCondition != nullptr)
162162
{
163-
const IntegerExpressionType& type = ctx.getIntegerType(false, caseValue->getType()->getIntegerBitWidth());
163+
auto bits = static_cast<unsigned short>(caseValue->getType()->getIntegerBitWidth());
164+
const IntegerExpressionType& type = ctx.getIntegerType(false, bits);
164165
Expression* numericConstant = ctx.numeric(type, caseValue->getLimitedValue());
165166
caseCondition = ctx.nary(NAryOperatorExpression::Equal, testVariable, numericConstant);
166167
}

fcd/ast/pre_ast_cfg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
class AstContext;
4242
class Expression;
43-
class PreAstBasicBlock;
43+
struct PreAstBasicBlock;
4444

4545
struct PreAstBasicBlockEdge
4646
{

fcd/codegen/translation_context.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,6 @@ Function* TranslationContext::createFunction(uint64_t baseAddress)
312312
break;
313313
}
314314

315-
#if DEBUG && 0
316-
// check that it still works
317-
if (verifyModule(*module, &errs()))
318-
{
319-
module->dump();
320-
abort();
321-
}
322-
#endif
323-
324315
return fn;
325316
}
326317

fcd/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ namespace
544544
phaseTwo.add(createCFGSimplificationPass());
545545
phaseTwo.run(module);
546546

547-
#if DEBUG
547+
#ifdef FCD_DEBUG
548548
if (verifyModule(module, &errorOutput))
549549
{
550550
// errors!
@@ -568,7 +568,7 @@ namespace
568568
}
569569
passManager.run(module);
570570

571-
#ifdef DEBUG
571+
#ifdef FCD_DEBUG
572572
if (verifyModule(module, &errorOutput))
573573
{
574574
// errors!

fcd/not_null.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#include <llvm/Support/Casting.h>
1818

19-
#ifdef DEBUG
19+
#ifdef FCD_DEBUG
2020

2121
// Smart pointer class to enforce that the pointer isn't null, and yell loudly if it is.
2222
template<typename T>

fcd/python/python_context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace
118118
RegisterPass<PythonWrappedFunction> pyFuncPass("#py-function-pass", "Python-wrapped function pass", false, false);
119119
}
120120

121-
#if DEBUG
121+
#ifdef FCD_DEBUG
122122
// needs external linkage to be available during debugging
123123
void dump(PyObject* obj)
124124
{

0 commit comments

Comments
 (0)