public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: LIU Hao <lh_mouse@126.com>
To: "gcc-rust@gcc.gnu.org" <gcc@gcc.gnu.org>
Subject: [PATCH] Fix rust on *-w64-mingw32
Date: Thu, 25 Apr 2024 19:16:31 +0800	[thread overview]
Message-ID: <79bd7ab5-b908-400d-b0a6-1faf1193bc61@126.com> (raw)


[-- Attachment #1.1.1: Type: text/plain, Size: 270 bytes --]

Hello,

Attached is a patch for fixing build issues on *-w64-mingw32. Please check and update at your leisure.

'gcc/system.h'  contains a macro called `mkdir()` and there is no need to invoke `_mkdir()` within a 
conditional block.

-- 
Best regards,
LIU Hao

[-- Attachment #1.1.2: gcc_master_rust.patch --]
[-- Type: text/plain, Size: 1870 bytes --]

diff --git a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
index 5daa7eb8ded..aff0c372789 100644
--- a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
@@ -28,13 +28,7 @@ void
 mkdir_wrapped (const std::string &dirname)
 {
   int ret;
-#ifdef _WIN32
-  ret = _mkdir (dirname.c_str ());
-#elif unix
   ret = mkdir (dirname.c_str (), 0775);
-#elif __APPLE__
-  ret = mkdir (dirname.c_str (), 0775);
-#endif
   (void) ret;
 }
 
diff --git a/gcc/rust/expand/rust-proc-macro.cc b/gcc/rust/expand/rust-proc-macro.cc
index 09680733e98..3518bffaf03 100644
--- a/gcc/rust/expand/rust-proc-macro.cc
+++ b/gcc/rust/expand/rust-proc-macro.cc
@@ -102,6 +102,7 @@ static_assert (
 
 } // namespace
 
+#ifndef _WIN32
 template <typename Symbol, typename Callback>
 bool
 register_callback (void *handle, Symbol, std::string symbol_name,
@@ -125,6 +126,7 @@ register_callback (void *handle, Symbol, std::string symbol_name,
 
 #define REGISTER_CALLBACK(HANDLE, SYMBOL, CALLBACK)                            \
   register_callback (HANDLE, SYMBOL, #SYMBOL, CALLBACK)
+#endif  // _WIN32
 
 const ProcMacro::ProcmacroArray *
 load_macros_array (std::string path)
diff --git a/gcc/rust/parse/rust-parse.cc b/gcc/rust/parse/rust-parse.cc
index 504a409cc4d..b78ac524f61 100644
--- a/gcc/rust/parse/rust-parse.cc
+++ b/gcc/rust/parse/rust-parse.cc
@@ -89,7 +89,7 @@ extract_module_path (const AST::AttrVec &inner_attrs,
   // Source: rustc compiler
   // (https://github.com/rust-lang/rust/blob/9863bf51a52b8e61bcad312f81b5193d53099f9f/compiler/rustc_expand/src/module.rs#L174)
 #if defined(HAVE_DOS_BASED_FILE_SYSTEM)
-  path.replace ('/', '\\');
+  std::replace(path.begin(), path.end(), '/', '\\');
 #endif /* HAVE_DOS_BASED_FILE_SYSTEM */
 
   return path;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

             reply	other threads:[~2024-04-25 11:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 11:16 LIU Hao [this message]
2024-04-25 11:19 ` Jakub Jelinek
2024-04-26 10:47 ` Arthur Cohen
2024-04-26 11:14   ` LIU Hao
2024-04-27 15:57     ` LIU Hao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79bd7ab5-b908-400d-b0a6-1faf1193bc61@126.com \
    --to=lh_mouse@126.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).