Commit 0ed04aac8b
Changed files (2)
src/zig_clang.h
@@ -8,14 +8,32 @@
#ifndef ZIG_ZIG_CLANG_H
#define ZIG_ZIG_CLANG_H
-#include "stage1/stage2.h"
#include <inttypes.h>
#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+#define ZIG_EXTERN_C extern "C"
+#else
+#define ZIG_EXTERN_C
+#endif
// ATTENTION: If you modify this file, be sure to update the corresponding
// extern function declarations in the self-hosted compiler file
// src/clang.zig.
+// ABI warning
+struct Stage2ErrorMsg {
+ const char *filename_ptr; // can be null
+ size_t filename_len;
+ const char *msg_ptr;
+ size_t msg_len;
+ const char *source; // valid until the ASTUnit is freed. can be null
+ unsigned line; // 0 based
+ unsigned column; // 0 based
+ unsigned offset; // byte offset into source
+};
+
struct ZigClangSourceLocation {
unsigned ID;
};
build.zig
@@ -91,6 +91,20 @@ pub fn build(b: *Builder) !void {
exe.addBuildOption(bool, "have_llvm", enable_llvm);
if (enable_llvm) {
const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option);
+
+ const exe_cflags = [_][]const u8{
+ "-std=c++14",
+ "-D__STDC_CONSTANT_MACROS",
+ "-D__STDC_FORMAT_MACROS",
+ "-D__STDC_LIMIT_MACROS",
+ "-D_GNU_SOURCE",
+ "-fvisibility-inlines-hidden",
+ "-fno-exceptions",
+ "-fno-rtti",
+ "-Werror=type-limits",
+ "-Wno-missing-braces",
+ "-Wno-comment",
+ };
if (is_stage1) {
exe.addIncludeDir("src");
exe.addIncludeDir("deps/SoftFloat-3e/source/include");
@@ -109,28 +123,8 @@ pub fn build(b: *Builder) !void {
softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" });
exe.linkLibrary(softfloat);
- const exe_cflags = [_][]const u8{
- "-std=c++14",
- "-D__STDC_CONSTANT_MACROS",
- "-D__STDC_FORMAT_MACROS",
- "-D__STDC_LIMIT_MACROS",
- "-D_GNU_SOURCE",
- "-fvisibility-inlines-hidden",
- "-fno-exceptions",
- "-fno-rtti",
- "-Werror=type-limits",
- "-Wno-missing-braces",
- "-Wno-comment",
- };
exe.addCSourceFiles(&stage1_sources, &exe_cflags);
exe.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" });
- if (cmake_cfg == null) {
- // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
- // in a dependency on llvm::cfg::Update<llvm::BasicBlock*>::dump() which is
- // unavailable when LLVM is compiled in Release mode.
- const zig_cpp_cflags = exe_cflags ++ [_][]const u8{"-DNDEBUG=1"};
- exe.addCSourceFiles(&zig_cpp_sources, &zig_cpp_cflags);
- }
}
if (cmake_cfg) |cfg| {
// Inside this code path, we have to coordinate with system packaged LLVM, Clang, and LLD.
@@ -193,6 +187,15 @@ pub fn build(b: *Builder) !void {
}
} else {
// Here we are -Denable-llvm but no cmake integration.
+
+ // Adds the Zig C++ sources which both stage1 and stage2 need.
+ //
+ // We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
+ // in a dependency on llvm::cfg::Update<llvm::BasicBlock*>::dump() which is
+ // unavailable when LLVM is compiled in Release mode.
+ const zig_cpp_cflags = exe_cflags ++ [_][]const u8{"-DNDEBUG=1"};
+ exe.addCSourceFiles(&zig_cpp_sources, &zig_cpp_cflags);
+
for (clang_libs) |lib_name| {
exe.linkSystemLibrary(lib_name);
}