public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix rust on *-w64-mingw32
@ 2024-04-25 11:16 LIU Hao
  2024-04-25 11:19 ` Jakub Jelinek
  2024-04-26 10:47 ` Arthur Cohen
  0 siblings, 2 replies; 5+ messages in thread
From: LIU Hao @ 2024-04-25 11:16 UTC (permalink / raw)
  To: gcc-rust@gcc.gnu.org


[-- 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 --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-27 15:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 11:16 [PATCH] Fix rust on *-w64-mingw32 LIU Hao
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

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).