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

Building with Mingw32-make fails for Windows #564

Closed
kealist opened this issue Jul 7, 2017 · 26 comments
Closed

Building with Mingw32-make fails for Windows #564

kealist opened this issue Jul 7, 2017 · 26 comments
Assignees

Comments

@kealist
Copy link

kealist commented Jul 7, 2017

Using the default r3-make in the make directory. (Fork's note: excerpted to a gist, but it ends with this error):

mingw32-make[1]: Leaving directory 'C:/Users/kealist/Documents/git/kealist/ren-c/make'
echo "Going to build with 8 jobs"
Going to build with 8 jobs
mingw32-make -j 8 top
mingw32-make[1]: Entering directory 'C:/Users/kealist/Documents/git/kealist/ren-c/make'
mingw32-make[1]: *** No rule to make target 'objs\a-constants.obj', needed by 'r3.exe'.  Stop.
mingw32-make[1]: Leaving directory 'C:/Users/kealist/Documents/git/kealist/ren-c/make'
makefile.boot:104: recipe for target 'top' failed
mingw32-make: *** [top] Error 2

C:\Users\kealist\Documents\git\kealist\ren-c\make>

I'm sure part of the issue is the mkdir calls behaving irregularly for windows (i.e. -p is not valid for mkdir, newline not being detected as whitespace causing folder names to be appended with "mkdir")

I do not have msys installed, but haven't had to previously to build. Not sure if the No rule to make target 'objs\a-constants.obj', needed by 'r3.exe'. is an additional problem or if it is caused by the bad folder structure

@kealist
Copy link
Author

kealist commented Jul 8, 2017

Actually that machine does have MSYS on it, but my other machine without fails to build at another stage:

Builtin extensions
ext: Crypt: [Crypt ]
ext: Process: [Process ]
ext: PNG: [LodePNG uPNG ]
ext: GIF: [GIF ]
ext: JPG: [JPG ]
ext: BMP: [BMP ]
ext: Locale: [Locale ]
ext: UUID: [UUID ]
Dynamic extensions
#SYMBOLS=""
'#SYMBOLS' is not recognized as an internal or external command,
operable program or batch file.
makefile.boot:117: recipe for target 'makefile' failed
mingw32-make: *** [makefile] Error 1

@zsx
Copy link

zsx commented Jul 8, 2017

For "mkdir", I think the issue is that rebmake doesn't know enough about the building environment, think that how many ways it can build for Windows:

  1. Cross-compilation on Linux for windows with mingw, the command should be like "mkdir -p objs/bmp"
  2. Use msys on Windows, same as linux
  3. Use mingw-make on Windows, calls native mkdir, and the command should be like "mkdir objs\bmp"

So neither the command ("mkdir -p" or "mkdir"), nor the directory format ("objs/bmp" or "objs\bmp"), can be determined solely by the target platform, the toolset, or their combinations.

The old building system didn't have this problem probably because it put everything under "objs", and a simple "mkdir objs" was enough and worked for all situations. But a potential problem with that is that we can't have source files with same name. That wasn't a problem because all source files were in the same directory (selectively compiled), and they had to be unique (thus the object file name deferred from them would be unique as well). As we move/add more stuffs as extensions, that can't be guaranteed because they are in their own directories: e.g. these files can both exist: src/extension/foo/foo.c, src/extension/bar/foo.c, it wouldn't work without creating subdirectories for extensions.

Maybe we can add variations of makefile to give rebmake enough info, i.e. TARGET=msys-makefile or TARGET=mingw-makefile

@zsx zsx self-assigned this Jul 8, 2017
@kealist
Copy link
Author

kealist commented Jul 8, 2017

I think the -p is less of a problem at this point as much as needing a space character at the end of the line containing mkdir because of some CR/LF madness that happens with the script.

I say that because many of the folders end up with the wrong name as in NAMEmkdir

@kealist
Copy link
Author

kealist commented Jul 8, 2017

Additionally on plain MinGW, I have this issue:

cflags: []
ldflags: [<gnu:-mconsole> <msc:/subsystem:console> <gnu:-Wl,--stack=4194300> <msc:/stack:4194300>]
debug: true
optimization: 2
Builtin extensions
ext: Crypt: [Crypt ]
ext: Process: [Process ]
ext: PNG: [LodePNG uPNG ]
ext: GIF: [GIF ]
ext: JPG: [JPG ]
ext: BMP: [BMP ]
ext: Locale: [Locale ]
ext: UUID: [UUID ]
Dynamic extensions
#SYMBOLS=""
'#SYMBOLS' is not recognized as an internal or external command,
operable program or batch file.
makefile.boot:117: recipe for target 'makefile' failed
mingw32-make: *** [makefile] Error 1

@zsx
Copy link

zsx commented Jul 9, 2017

@kealist Could you try directly compiling without generating a makefile?

  1. copy %make/configs/mingw-x64.r to your-config.r, and change the path of toolsets
  2. Run:
./r3-make.exe ../src/tools/make-make.r CONFIG=configs/your-config.r TARGET=execution

I'll take a look at building with MingW and Makefile on Windows.

@kealist
Copy link
Author

kealist commented Jul 9, 2017

./ doesn't work with MinGW alone by default so it's failing on most steps for me (I always have to change CD = ./ in my makefile), also I don't have FFI installed, so that is causing problems

@zsx
Copy link

zsx commented Jul 9, 2017

@kealist You can change all of these in your config.r or command line (check %make/default-config.r for what you can customize):

r3-make.exe ../src/tools/make-make.r CONFIG=configs/your-config.r TARGET=execution REBOL_TOOL=r3-make.exe WITH_FFI="no"

@kealist
Copy link
Author

kealist commented Jul 9, 2017

@zsx Thank you. That built all the object files and didn't have messiness with folders. Did not build r3.exe however (just stopped after libuuid).

@zsx
Copy link

zsx commented Jul 9, 2017

@kealist Did you see any error? if so, could you show me the output? if not, you might need to clean up first:

r3-make.exe ../src/tools/make-make.r CONFIG=configs/your-config.r TARGET=clean REBOL_TOOL=r3-make.exe WITH_FFI="no"

Because the EXECUTION target doesn't check the timestamp of the target file to decide if the command needs to run. It just checks its existence, because tracking timestamp of all of dependencies seems to be too much work, and I want to keep it simple. So just run the target "clean" in case if fails to follow the updated dependencies.

@kealist
Copy link
Author

kealist commented Jul 9, 2017

@zsx I cleaned manually and rebuilt it and it built & ran without error at this time. I actually built mingw-x86.r config, not mingw-x64.r, I did just try x64 though and it didn't work at all. Maybe mingw32 bit can't compile 64 bit

@zsx
Copy link

zsx commented Jul 9, 2017

@kealist right, I think you need mingw64 to compile 64-bit binaries.

@codebybrett
Copy link

@zsx I understand you're still looking at this - I'll just add the error I got when I just tried (9f0beb9):

...
mkdir -p objs\uuid\
mkdir -p objs\windows\

mkdir: cannot create directory `objs\\crypt\\aesmkdir': No such file or directory
mkdir: cannot create directory `objs\\crypt\\bigintmkdir': No such file or directory
mkdir: cannot create directory `objs\\crypt\\dhmkdir': No such file or directory
mkdir: cannot create directory `objs\\crypt\\rc4mkdir': No such file or directory
mkdir: cannot create directory `objs\\crypt\\rsamkdir': No such file or directory
mkdir: cannot create directory `objs\\crypt\\sha256mkdir': No such file or directory
makefile:8: recipe for target 'folders' failed
mingw32-make[1]: *** [folders] Error 1
mingw32-make[1]: Leaving directory 'C:/Projects/Public/ren-c/make'
makefile.boot:104: recipe for target 'top' failed
mingw32-make: *** [top] Error 2

@kealist
Copy link
Author

kealist commented Jul 13, 2017

@codebybrett If you follow the instructions above, you should be able to compile.

First, modify a config file %myconfig.r. Mine is simply:

REBOL []

os-id: 0.3.1
rebol-tool: %r3-make.exe
toolset: [
    gcc %mingw32-gcc
    ld %mingw32-gcc; linking is done via calling gcc, not ld
    strip %strip
]
with-ffi: no

Then from my console, I run:

r3-make.exe ../src/tools/make-make.r CONFIG=configs/myconfig.r TARGET=execution

I manually delete r3.exe and the objs/ folder before building. Or you can run TARGET=clean (not done automatically)

@codebybrett
Copy link

Thanks @kealist, that gives me a build.

@zsx
Copy link

zsx commented Jul 13, 2017

@kealist @codebybrett Please test the latest code, and see if it builds with mingw-make

@kealist
Copy link
Author

kealist commented Jul 14, 2017

@zsx Using makefile: No. Using the steps above: built fine.

@codebybrett
Copy link

codebybrett commented Jul 14, 2017

I pulled in 0f12936

Using this:

r3-make.exe ../src/tools/make-make.r CONFIG=configs/myconfig.r TARGET=execution

I get this failure:

Expected 6 and 5, got 6 and 0
C Source File ..\src\core\b-init.c, Line 112
Rebol Internal Error
If you need to file a bug in the issue tracker, please give thorough
details on how to reproduce the problem:

    https://github.com/metaeducation/ren-c/issues

Include the following information in the report:


Bad composed integer assignment for byte-ordering macro.

Using:

mingw32-make -f makefile.boot

I get lot's of possibly spurious errors - the first being:

gcc -c -I..\src\include -DREB_API -DENDIAN_LITTLE -DUNICODE -D_FILE_OFFSET_BITS=64 -D__LLP64__ -DTO_WINDOWSII nn-  Dfile included from ..\src\include/sys-core.h:178:0,
                ffile included from ..\src\include/sys-core.h:178:0,
                from ..\src\core\a-globals.c:39:
..\src\include/sys-value.h: In function 'VAL_RESET_HEADER_common':
rom ..\src\cor..\src\include/reb-c.h:1030:24: warning: left shift count >= width of type [-Wshift-count-overflow]
        ((REBUPT)(vale\a-constants.c:44:
..\src\include/sys-value.h: In function 'VAL_RESET_HEADER_common':
TIn fi)O_WINDOWS_X64 -O2 -g  << (PLATFORM_BITS - In file 8)) // v-g3  -o objs\c-bind.obj ..\srle included from ..\src\include/sys-core.h:178:0,
                from ..\src\core\b-init.c:48:
..\src\include/sys-value.h: In function 'VAL_RESET_HEADER_commonalin': <= 255
cluded
                    ^
..\src\include/sys-rebval.h:283:5: note:.. frc\core\c-bind.c
\src\include/reb-c.h:1030:24: warning: left shift count >= width of type [-Wshi. oftin expansion of macro 'FLAGBYTE_RIGH-count-overflow]
        ((REBUPT)(val) <m.T< (PLA'
    FLAGBYTE_RIGHT(kind)
gcc -c -I..\src\include -DREB_API \TFORM_ -DENDIAN_LITTLE -DUNICODE -D_FILE_OFFSET_BITS=64 -D__LL  P64__ -DTO_WINDOWS -D..\BITS TO_WINDOWS_X64 -O2 -g -g3  -o objs\c-do.obj ..\src\core\c-do.c
- 8)) // ssrc\include/reb-c.h:1030:24: warninvr g: left shal <= 255
...

Note the inconsistent path convention above.

@codebybrett
Copy link

@kealist With the build you got - does it run ok?

@kealist
Copy link
Author

kealist commented Jul 14, 2017

@codebybrett Just tested with a fresh clone and both times the executable ran.

@zsx
Copy link

zsx commented Jul 14, 2017

@kealist @codebybrett how did you install mingw-make, I want to install on my computer to test it locally. I only have msys2 to test with.

@kealist
Copy link
Author

kealist commented Jul 14, 2017

@codebybrett
Copy link

@zsx I believe I used the same link as kealist, Not sure which package option.

I set the path in a command file I use to build ren-c:

cd ren-c
for /f %%i in ('git rev-parse head') do set GIT_COMMIT=%%i
cd ..

SET PATH=%PATH%;C:\MinGW\msys\1.0\bin;C:\MinGW\bin
cd ren-c/make
del objs /s /q

mingw32-make -f makefile.boot

REM To use config file instead...
REM r3-make.exe ../src/tools/make-make.r CONFIG=configs/myconfig.r TARGET=execution

copy r3.exe ..\..\renc.exe

@kealist
Copy link
Author

kealist commented Jul 14, 2017

My path is just C:\MinGW\bin. @codebybrett Make sure to delete any previous r3.exe file too.

@hostilefork
Copy link
Member

hostilefork commented Apr 21, 2018

Bump... @kealist, is this resolved at this point? Things are different after Giuliolunati's make changes...

@kealist
Copy link
Author

kealist commented Apr 23, 2018

I'll try it this evening

@kealist
Copy link
Author

kealist commented Apr 24, 2018

Seems to work find. I am closing.

@kealist kealist closed this as completed Apr 24, 2018
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

4 participants