Failing to build on cygwin: fsync

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
igorgatis
Posts: 21
Joined: Thu Nov 19, 2015 1:10 pm

Failing to build on cygwin: fsync

Post by igorgatis » Thu Nov 19, 2015 1:34 pm

I'm trying to build micropy on Cygwin without success. First thing I had to do was change UNIX with _WIN32 (patch below). Now, It fails with

Code: Select all

../unix/file.c: In function ‘fdfile_flush’:
../unix/file.c:43:15: error: implicit declaration of function ‘_commit’ [-Werror=implicit-function-declaration]
 #define fsync _commit
               ^
../unix/file.c:112:5: note: in expansion of macro ‘fsync’
     fsync(self->fd);
I even added #include <io.h> to unix/file.c but that didn't seem to make any difference. Any suggestions?

Patch:

Code: Select all

diff --git a/windows/Makefile b/windows/Makefile
index d791735..7252f05 100644
--- a/windows/Makefile
+++ b/windows/Makefile
@@ -15,7 +15,7 @@ INC += -I..
 INC += -I$(BUILD)

 # compiler settings
-CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT)
+CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -D_WIN32 -D__USE_MINGW_ANSI_STDIO=1 $(CFLAGS_MOD) $(COPT)
 LDFLAGS = $(LDFLAGS_MOD) -lm

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Failing to build on cygwin: fsync

Post by pfalcon » Thu Nov 19, 2015 2:03 pm

You're doing something wrong. If you want to build native Cygwin, then you just build unix port with it. If you want to build using mingw32/mingw64, then you need to build native Windows port in windows/ .
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

igorgatis
Posts: 21
Joined: Thu Nov 19, 2015 1:10 pm

Re: Failing to build on cygwin: fsync

Post by igorgatis » Thu Nov 19, 2015 3:06 pm

Got it. Just tried using unix port. I set MICROPY_PY_FFI=0 so it ignores the lack of libffi. Now assembler complains:

Code: Select all

../py/nlrx86.S: Assembler messages:
../py/nlrx86.S:56: Warning: .type pseudo-op used outside of .def/.endef ignored.
../py/nlrx86.S:56: Error: junk at end of line, first unrecognized character is `n'
../py/nlrx86.S:73: Warning: .size pseudo-op used outside of .def/.endef ignored.
../py/nlrx86.S:73: Error: junk at end of line, first unrecognized character is `n'
../py/nlrx86.S:85: Warning: .type pseudo-op used outside of .def/.endef ignored.
...(bunch of lines alike)...
I checked ../py/nlrx86.S and I noticed it checks _WIN32 is defined. When I add -D_WIN32 to build command line, #define fsync _commit problem happens again.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Failing to build on cygwin: fsync

Post by pfalcon » Thu Nov 19, 2015 3:29 pm

Ok, so patching nlrx86.S makes sense, the logic of that check should be _WIN32 || __CYGWIN__ (check actual macro name to use of course).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: Failing to build on cygwin: fsync

Post by pfalcon » Thu Nov 19, 2015 3:35 pm

(Once you get it to work, please don't forget to submit pull request.)
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/


Post Reply