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

MSYS2 64-bit's gcc does not define __WIN32__ by default #45

Closed
abonander opened this issue Dec 28, 2014 · 3 comments
Closed

MSYS2 64-bit's gcc does not define __WIN32__ by default #45

abonander opened this issue Dec 28, 2014 · 3 comments

Comments

@abonander
Copy link
Contributor

I'm getting an error for missing symbols in time_helpers.c:

note: D:\Git\img_dup\target\deps\libtime-040b8fe6da930644.rlib(r-time_helpers-time_helpers.o):time_helpers.c:(.text$rust_time_gmtime+0x27): undefined reference to `gmtime_r'
D:\Git\img_dup\target\deps\libtime-040b8fe6da930644.rlib(r-time_helpers-time_helpers.o):time_helpers.c:(.text$rust_time_localtime+0x27): undefined reference to `localtime_r'
ld: D:\Git\img_dup\target\deps\libtime-040b8fe6da930644.rlib(r-time_helpers-time_helpers.o): bad reloc address 0x27 in section `.text$rust_time_localtime'

This is a fresh MSYS2 install, plus gcc grabbed through the included pacman.

It looks like the C preprocessor isn't predefining __WIN32__ unless -mwin32 is passed:

$ gcc -m64 -dM -E -x c /dev/null | grep "WIN"
#define __WINT_MAX__ 4294967295U
#define __WINT_MIN__ 0U
#define __SIZEOF_WINT_T__ 4
#define __CYGWIN__ 1
#define __WINT_TYPE__ unsigned int

$ gcc -mwin32 -dM -E -x c /dev/null | grep "WIN"
#define _WIN32 1
#define __WINT_MAX__ 4294967295U
#define __WINT_MIN__ 0U
#define __WIN32 1
#define __WIN32__ 1
#define __SIZEOF_WINT_T__ 4
#define __CYGWIN__ 1
#define WIN32 1
#define __WINT_TYPE__ unsigned int
#define WINNT 1

Not sure if this belongs here or gcc-rs. Patching time to add the -mwin32 flag for target_os = "windows" did the trick, then I needed to get tchar.h from pacman -S mingw-w64-x86_64-headers and copy it into /usr/include.

@alexcrichton
Copy link

It sounds like adding -mwin32 to gcc-rs is a good idea! Want to submit a PR for that?

@abonander
Copy link
Contributor Author

@alexcrichton PR submitted!

@alexcrichton
Copy link

Closing in favor of rust-lang/cc-rs#19, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants