Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build on MinGW-w64 #2843

Open
MehdiChinoune opened this issue Feb 9, 2024 · 2 comments
Open

Fails to build on MinGW-w64 #2843

MehdiChinoune opened this issue Feb 9, 2024 · 2 comments
Labels
windows/wine DOS-related issue
Milestone

Comments

@MehdiChinoune
Copy link

I tried to build gcc-14 with rust enabled, but It fails to build.
It needs some changes to build

1 -

--- a/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
+++ b/gcc/rust/checks/errors/borrowck/rust-borrow-checker.cc
@@ -20,6 +20,11 @@
 #include "rust-function-collector.h"
 #include "rust-bir-builder.h"
 #include "rust-bir-dump.h"
+
+#ifdef _WIN32
+#define NO_OLDNAMES
+#include <direct.h>
+#endif
 
 namespace Rust {
 namespace HIR {

to recognize _mkdir function

2 -

--- a/gcc/rust/expand/rust-proc-macro.cc
+++ b/gcc/rust/expand/rust-proc-macro.cc
@@ -102,6 +102,7 @@
 
 } // namespace
 
+#ifndef _WIN32
 template <typename Symbol, typename Callback>
 bool
 register_callback (void *handle, Symbol, std::string symbol_name,
@@ -125,6 +126,7 @@
 
 #define REGISTER_CALLBACK(HANDLE, SYMBOL, CALLBACK)                            \
   register_callback (HANDLE, SYMBOL, #SYMBOL, CALLBACK)
+#endif
 
 const ProcMacro::ProcmacroArray *
 load_macros_array (std::string path)

dlsym is a posix function, so it doesn't exist on Windows.

3 -

--- a/gcc/rust/parse/rust-parse.cc
+++ b/gcc/rust/parse/rust-parse.cc
@@ -89,7 +89,7 @@
   // 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;

gcc doesn't accept path.replace ('/', '\\')

@lhmouse
Copy link
Contributor

lhmouse commented Apr 30, 2024

@P-E-P
Copy link
Member

P-E-P commented May 6, 2024

I've been trying to set up a CI in #2979, there is a small problem remaining but when it'll be merged this should'nt happen anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
windows/wine DOS-related issue
Projects
None yet
Development

No branches or pull requests

4 participants