Skip to content

Commit e9ab95c

Browse files
Merge #1109
1109: rust: Allow gccrs to build on x86_64-apple-darwin with clang/libc++ r=CohenArthur a=simonpcook This makes changes to the includes such that gccrs can be built with clang/libc++, and for x86_64-apple-darwin. Similarly, a couple of changes have been made to creating MacroInvocations and wrapping into ExprOrStmts for libc++ compatibility. Co-authored-by: Simon Cook <[email protected]>
2 parents 7430791 + 1a3f38a commit e9ab95c

23 files changed

+22
-47
lines changed

gcc/rust/ast/rust-path.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323

2424
#include "rust-ast.h"
2525

26-
#include <string>
27-
#include <vector>
28-
2926
namespace Rust {
3027
namespace AST {
3128

gcc/rust/backend/rust-mangle.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "rust-mangle.h"
22
#include "fnv-hash.h"
33
#include "rust-base62.h"
4-
#include <algorithm>
54

65
// FIXME: Rename those to legacy_*
76
static const std::string kMangledSymbolPrefix = "_ZN";

gcc/rust/expand/rust-macro-builtins.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
* of the `Mappings` class.
6060
*/
6161

62+
/* If assert is defined as a macro this file will not parse, so undefine this
63+
before continuing. */
64+
#ifdef assert
65+
#undef assert
66+
#endif
67+
6268
namespace Rust {
6369
class MacroBuiltin
6470
{

gcc/rust/hir/tree/rust-hir-path.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
#include "rust-hir.h"
2323

24-
#include <string>
25-
#include <vector>
26-
2724
namespace Rust {
2825
namespace HIR {
2926

gcc/rust/lex/rust-lex.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include "rust-linemap.h"
2424
#include "safe-ctype.h"
2525

26-
#include <sstream> // for ostringstream
27-
2826
namespace Rust {
2927
// TODO: move to separate compilation unit?
3028
// overload += for uint32_t to allow 32-bit encoded utf-8 to be added

gcc/rust/lex/rust-lex.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#include "rust-buffered-queue.h"
2424
#include "rust-token.h"
2525

26-
#include <cstdio>
27-
#include <utility>
28-
#include <tuple>
29-
3026
namespace Rust {
3127
// Simple wrapper for FILE* that simplifies destruction.
3228
struct RAIIFile

gcc/rust/lex/rust-token.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#ifndef RUST_TOKEN_H
2020
#define RUST_TOKEN_H
2121

22-
#include <string>
23-
#include <memory>
24-
2522
#include "rust-linemap.h"
2623
#include "rust-codepoint.h"
2724

gcc/rust/lint/rust-lint-marklive.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#ifndef RUST_HIR_LIVENESS
2020
#define RUST_HIR_LIVENESS
2121

22-
#include <set>
2322
#include "rust-hir-full-decls.h"
2423
#include "rust-hir-map.h"
2524
#include "rust-lint-marklive-base.h"

gcc/rust/lint/rust-lint-scan-deadcode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#ifndef RUST_HIR_SCAN_DEADCODE
2020
#define RUST_HIR_SCAN_DEADCODE
2121

22-
#include <set>
2322
#include "rust-hir-full-decls.h"
2423
#include "rust-hir-map.h"
2524
#include "rust-lint-marklive.h"

gcc/rust/parse/rust-cfg-parser.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ along with GCC; see the file COPYING3. If not see
1818
#define RUST_CFG_PARSER_H
1919

2020
#include "config.h"
21-
#include "system.h"
21+
#include "rust-system.h"
2222
#include "coretypes.h"
2323

24-
#include <string>
25-
2624
namespace Rust {
2725
/**
2826
* Parse a `key` or `key="value"` pair given to the `-frust-cfg` compiler

gcc/rust/parse/rust-parse-impl.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11923,17 +11923,15 @@ Parser<ManagedTokenSource>::parse_path_based_stmt_or_expr (
1192311923
std::unique_ptr<AST::MacroInvocation> stmt (
1192411924
new AST::MacroInvocation (std::move (invoc_data),
1192511925
std::move (outer_attrs),
11926-
stmt_or_expr_loc),
11927-
true);
11926+
stmt_or_expr_loc, true));
1192811927
return ExprOrStmt (std::move (stmt));
1192911928
}
1193011929

1193111930
// otherwise, create macro invocation
1193211931
std::unique_ptr<AST::MacroInvocation> expr (
1193311932
new AST::MacroInvocation (std::move (invoc_data),
1193411933
std::move (outer_attrs),
11935-
stmt_or_expr_loc),
11936-
false);
11934+
stmt_or_expr_loc, false));
1193711935
return ExprOrStmt (std::move (expr));
1193811936
}
1193911937
else
@@ -12244,8 +12242,8 @@ Parser<ManagedTokenSource>::parse_macro_invocation_maybe_semi (
1224412242

1224512243
std::unique_ptr<AST::MacroInvocation> stmt (
1224612244
new AST::MacroInvocation (std::move (invoc_data),
12247-
std::move (outer_attrs), macro_locus),
12248-
true);
12245+
std::move (outer_attrs), macro_locus,
12246+
true));
1224912247
return ExprOrStmt (std::move (stmt));
1225012248
}
1225112249

gcc/rust/parse/rust-parse.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ struct ExprOrStmt
4040
// statement constructor
4141
ExprOrStmt (std::unique_ptr<AST::Stmt> stmt) : stmt (std::move (stmt)) {}
4242

43+
// macro constructor
44+
ExprOrStmt (std::unique_ptr<AST::MacroInvocation> macro)
45+
: expr (std::move (macro))
46+
{}
47+
4348
// Returns whether this object is in an error state.
4449
bool is_error () const
4550
{

gcc/rust/rust-buffered-queue.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#ifndef RUST_BUFFERED_QUEUE_H
2020
#define RUST_BUFFERED_QUEUE_H
2121

22-
#include <vector>
23-
#include <utility>
24-
2522
#include "rust-system.h"
2623

2724
namespace Rust {

gcc/rust/rust-session-manager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "rust-backend.h"
2525

2626
#include "config.h"
27-
#include "system.h"
27+
#include "rust-system.h"
2828
#include "coretypes.h"
2929
#include "options.h"
3030

gcc/rust/rust-system.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
#include <deque>
4242
#include <functional>
4343
#include <memory>
44+
#include <utility>
45+
#include <fstream>
4446

4547
// Rust frontend requires C++11 minimum, so will have unordered_map and set
4648
#include <unordered_map>

gcc/rust/typecheck/rust-hir-type-check-util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef RUST_HIR_TYPE_CHECK_UTIL_H
2020
#define RUST_HIR_TYPE_CHECK_UTIL_H
2121

22-
#include <functional>
22+
#include "rust-system.h"
2323
#include "rust-hir-visitor.h"
2424

2525
namespace Rust {

gcc/rust/typecheck/rust-tycheck-dump.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#include "rust-hir-type-check-base.h"
2323
#include "rust-hir-full.h"
2424

25-
#include <fstream>
26-
#include <sstream>
27-
2825
namespace Rust {
2926
namespace Resolver {
3027

gcc/rust/util/fnv-hash.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#ifndef RUST_FNV_HASH_H
2020
#define RUST_FNV_HASH_H
2121

22-
#include <cstdint>
23-
#include <cstddef>
24-
2522
namespace Rust {
2623
namespace Hash {
2724

gcc/rust/util/rust-abi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef RUST_ABI_OPTIONS_H
1818
#define RUST_ABI_OPTIONS_H
1919

20-
#include <string>
20+
#include "rust-system.h"
2121

2222
namespace Rust {
2323

gcc/rust/util/rust-base62.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
#include "rust-base62.h"
2020

21-
#include <algorithm>
22-
2321
namespace Rust {
2422

2523
std::string

gcc/rust/util/rust-base62.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifndef RUST_BASE62_H
2020
#define RUST_BASE62_H
2121

22-
#include <string>
22+
#include "rust-system.h"
2323

2424
namespace Rust {
2525

gcc/rust/util/rust-inline-visitor.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
#ifndef RUST_INLINE_VISITOR
2323
#define RUST_INLINE_VISITOR
2424

25-
#include <utility>
26-
#include <type_traits>
27-
2825
namespace Rust {
2926

3027
// Wrapper for the target Visitor we're matching against.

gcc/rust/util/rust-make-unique.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef RUST_MAKE_UNIQUE_H
22
#define RUST_MAKE_UNIQUE_H
33

4-
#include <memory>
5-
64
namespace Rust {
75

86
template <typename T, typename... Ts>

0 commit comments

Comments
 (0)