lunarmodules / luasystem

Platform independent system calls for Lua
http://lunarmodules.github.io/luasystem/
MIT License
20 stars 12 forks source link

Error when install: Error: Build error: Failed compiling object src/term.o #29

Closed Ryuu-64 closed 2 months ago

Ryuu-64 commented 3 months ago

Here is the console log. I wonder why it failed. I'm using "x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z" "lua-5.4.2_Win64_vc17_lib.zip" and "lua-5.4.2_Win64_bin.zip". Would anyone be able to help?

luarocks install luasystem
Installing https://luarocks.org/luasystem-0.4.1-1.src.rock

luasystem 0.4.1-1 depends on lua >= 5.1 (5.4-1 provided by VM: success)
x86_64-w64-mingw32-gcc -O2 -c -o src/core.o -ID:\Program Files\Lua/include src/core.c -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -Ic:\windows\system32\include -Ic:\windows\system32\include
x86_64-w64-mingw32-gcc -O2 -c -o src/compat.o -ID:\Program Files\Lua/include src/compat.c -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -Ic:\windows\system32\include -Ic:\windows\system32\include
x86_64-w64-mingw32-gcc -O2 -c -o src/time.o -ID:\Program Files\Lua/include src/time.c -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -Ic:\windows\system32\include -Ic:\windows\system32\include
x86_64-w64-mingw32-gcc -O2 -c -o src/environment.o -ID:\Program Files\Lua/include src/environment.c -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -Ic:\windows\system32\include -Ic:\windows\system32\include
x86_64-w64-mingw32-gcc -O2 -c -o src/random.o -ID:\Program Files\Lua/include src/random.c -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -Ic:\windows\system32\include -Ic:\windows\system32\include
x86_64-w64-mingw32-gcc -O2 -c -o src/term.o -ID:\Program Files\Lua/include src/term.c -DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -Ic:\windows\system32\include -Ic:\windows\system32\include
src/term.c:126:59: error: 'ENABLE_VIRTUAL_TERMINAL_INPUT' undeclared here (not in a function); did you mean 'ENABLE_LINE_INPUT'?
     {"CIF_VIRTUAL_TERMINAL_INPUT", CHECK_WIN_FLAG_OR_ZERO(ENABLE_VIRTUAL_TERMINAL_INPUT)},
                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:136:64: error: 'ENABLE_VIRTUAL_TERMINAL_PROCESSING' undeclared here (not in a function)
     {"COF_VIRTUAL_TERMINAL_PROCESSING", CHECK_WIN_FLAG_OR_ZERO(ENABLE_VIRTUAL_TERMINAL_PROCESSING)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:136:64: warning: initialization of 'long unsigned int' from 'const struct ls_RegConst *' makes integer from pointer without a cast [-Wint-conversion]
     {"COF_VIRTUAL_TERMINAL_PROCESSING", CHECK_WIN_FLAG_OR_ZERO(ENABLE_VIRTUAL_TERMINAL_PROCESSING)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:136:64: note: (near initialization for 'win_console_out_flags[2].value')
     {"COF_VIRTUAL_TERMINAL_PROCESSING", CHECK_WIN_FLAG_OR_ZERO(ENABLE_VIRTUAL_TERMINAL_PROCESSING)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:136:64: error: initializer element is not constant
     {"COF_VIRTUAL_TERMINAL_PROCESSING", CHECK_WIN_FLAG_OR_ZERO(ENABLE_VIRTUAL_TERMINAL_PROCESSING)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:136:64: note: (near initialization for 'win_console_out_flags[2].value')
     {"COF_VIRTUAL_TERMINAL_PROCESSING", CHECK_WIN_FLAG_OR_ZERO(ENABLE_VIRTUAL_TERMINAL_PROCESSING)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:137:64: error: 'DISABLE_NEWLINE_AUTO_RETURN' undeclared here (not in a function)
     {"COF_DISABLE_NEWLINE_AUTO_RETURN", CHECK_WIN_FLAG_OR_ZERO(DISABLE_NEWLINE_AUTO_RETURN)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:137:64: warning: initialization of 'long unsigned int' from 'const struct ls_RegConst *' makes integer from pointer without a cast [-Wint-conversion]
     {"COF_DISABLE_NEWLINE_AUTO_RETURN", CHECK_WIN_FLAG_OR_ZERO(DISABLE_NEWLINE_AUTO_RETURN)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:137:64: note: (near initialization for 'win_console_out_flags[3].value')
     {"COF_DISABLE_NEWLINE_AUTO_RETURN", CHECK_WIN_FLAG_OR_ZERO(DISABLE_NEWLINE_AUTO_RETURN)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:137:64: error: initializer element is not constant
     {"COF_DISABLE_NEWLINE_AUTO_RETURN", CHECK_WIN_FLAG_OR_ZERO(DISABLE_NEWLINE_AUTO_RETURN)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:137:64: note: (near initialization for 'win_console_out_flags[3].value')
     {"COF_DISABLE_NEWLINE_AUTO_RETURN", CHECK_WIN_FLAG_OR_ZERO(DISABLE_NEWLINE_AUTO_RETURN)},
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:138:62: error: 'ENABLE_LVB_GRID_WORLDWIDE' undeclared here (not in a function)
     {"COF_ENABLE_LVB_GRID_WORLDWIDE", CHECK_WIN_FLAG_OR_ZERO(ENABLE_LVB_GRID_WORLDWIDE)},
                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:138:62: warning: initialization of 'long unsigned int' from 'const struct ls_RegConst *' makes integer from pointer without a cast [-Wint-conversion]
     {"COF_ENABLE_LVB_GRID_WORLDWIDE", CHECK_WIN_FLAG_OR_ZERO(ENABLE_LVB_GRID_WORLDWIDE)},
                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:138:62: note: (near initialization for 'win_console_out_flags[4].value')
     {"COF_ENABLE_LVB_GRID_WORLDWIDE", CHECK_WIN_FLAG_OR_ZERO(ENABLE_LVB_GRID_WORLDWIDE)},
                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:138:62: error: initializer element is not constant
     {"COF_ENABLE_LVB_GRID_WORLDWIDE", CHECK_WIN_FLAG_OR_ZERO(ENABLE_LVB_GRID_WORLDWIDE)},
                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~
src/term.c:138:62: note: (near initialization for 'win_console_out_flags[4].value')
     {"COF_ENABLE_LVB_GRID_WORLDWIDE", CHECK_WIN_FLAG_OR_ZERO(ENABLE_LVB_GRID_WORLDWIDE)},
                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~
src/term.c:109:38: note: in definition of macro 'CHECK_WIN_FLAG_OR_ZERO'
 #define CHECK_WIN_FLAG_OR_ZERO(flag) flag
                                      ^~~~

Error: Build error: Failed compiling object src/term.o
Tieske commented 3 months ago

What does your set up look like? What compiler toolchain are you using, how did you configure LuaRocks?

Ryuu-64 commented 2 months ago

Thanks for your reply.

This is my Lua Path: image

This is my MinGW Path: image

I found that the dependencies are compiled, but the compiler says things like "ENABLE_VIRTUAL_TERMINAL_INPUT" and "DISABLE_NEWLINE_AUTO_RETURN." are undeclared.

This causes the Lua system install to fail. Do you know how I can fix this? I am looking forward to hearing back from you.

Tieske commented 2 months ago

what windows version are you on?

Tieske commented 2 months ago

Also; make sure your paths are clean (do not mix different compilers) just to be sure. That zipfile has vc17 in the filename. Which means it was compiled using MS Visual C, and probably uses a different runtime than the MinGW compiler does.

You might want to give this a try;

tobil4sk commented 2 months ago

I ran into this as well when using hererocks (to install any lua version, luarocks seems to be 3.8.0) in a github actions windows-2019 environment. Changing to windows-2022 avoided the issue.

Tieske commented 2 months ago

That would explain it. This functionality was added to windows 10 somewhere 2019. Which is by now 5 years ago...

Would it be fair to state that one should stick to an older luasystem version, or upgrade to a later toolchain?

tobil4sk commented 2 months ago

Would it be fair to state that one should stick to an older luasystem version, or upgrade to a later toolchain?

It would be ideal to have some #if blocks to avoid this issue. I've only had a brief look at the code, but maybe you could just set it to zero if it isn't set? e.g.

#ifndef ENABLE_VIRTUAL_TERMINAL_INPUT
#define ENABLE_VIRTUAL_TERMINAL_INPUT 0
#endif

This seems in line with the comment here: https://github.com/lunarmodules/luasystem/blob/45499248cea9e23b7e4d8478759414e01c645809/src/term.c#L106-L108

If that can't be a solution, then having a note somewhere to specify which luasystem versions are supported on which toolchains would be useful.

Tieske commented 2 months ago

Since this is an OS version that is 5 years old, is out of support (and hence insecure), and usage will be diminishing, I'd vote to not add those #if blocks, but rather document it.

wdyt @o-lim, @alerque ?

o-lim commented 2 months ago

Since this is an OS version that is 5 years old, is out of support (and hence insecure), and usage will be diminishing, I'd vote to not add those #if blocks, but rather document it.

wdyt @o-lim, @alerque ?

That depends. What happens if this constant is not defined (or zero)? Would the term module still work as expected? Would any tests fail? Is enabling this feature critical to the functionality of the Lua module? I'm not familiar with the Windows terminal, so I don't know enough to answer any of these questions.

If the module just "doesn't work right" without this constant/feature, then is it possible to generate a more appropriate compile error message when the Windows version is too low? Something like:

#if WINVER < XXX
#error Windows version not supported, need at least version YYY for terminal support
#endif
Tieske commented 2 months ago

It would not work. Even worse, if you run it on a recent version of windows, but with the 2019 compiler. It would compile but not work. Very confusing imho.

I think @o-lim s suggestion of generating a more descriptive compile time error is probably the best option.

o-lim commented 2 months ago

I think @o-lim s suggestion of generating a more descriptive compile time error is probably the best option.

That sounds good to me.

Tieske commented 2 months ago

@Ryuu-64 @tobil4sk would you mind giving #32 a try? Doesn't fix your problem, but should get you a more descriptive error message.

Ryuu-64 commented 2 months ago

what windows version are you on?

My Windows version is: Windows 11 Professional 23H2 22631.3880 Windows Feature Experience Pack 1000.22700.1020.0

Ryuu-64 commented 2 months ago

@Ryuu-64 @tobil4sk would you mind giving #32 a try? Doesn't fix your problem, but should get you a more descriptive error message.

Thank you for your reply; I will give it a try.

Tieske commented 2 months ago

My Windows version is: Windows 11 Professional 23H2 22631.3880 Windows Feature Experience Pack 1000.22700.1020.0

@Ryuu-64 I think it's more related to the toolchain, than the actual Windows version. Since Windows does binary distributions, the actual OS doesn't include the header files for development. You only get those with the Windows SDK or with Visual Studio installation.

So what toolchain version were you using?

tobil4sk commented 2 months ago

@Ryuu-64 @tobil4sk would you mind giving https://github.com/lunarmodules/luasystem/pull/32 a try? Doesn't fix your problem, but should get you a more descriptive error message.

With this change, the first error displayed is the new error message: 2019 and older toolchains are not supported. Update the toolchain or revert to Luasystem < 0.4, followed by the undeclared define errors.

For the windows-2019 github actions image, it looks like the issue is due to an outdated mingw version. It is using a build that is missing this definition. It was only added in: https://sourceforge.net/p/mingw-w64/mingw-w64/ci/1b29d1bc58910a4c21ff2c5c804bf06821032348/. So for mingw users, this can be solved by using a newer mingw version.

Hopefully the windows-2019 image can be updated with a newer mingw build: https://github.com/actions/runner-images/issues/10352

tobil4sk commented 2 months ago

I'm using "x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z"

@Ryuu-64 This is the same version that the windows-2019 image is downloading from sourceforge. v6 of the mingw runtime is very old (from 2018), which is why it is missing these definitions. There are newer builds available here with newer versions of the mingw runtime: https://github.com/niXman/mingw-builds-binaries/releases. Using one of these should be the solution to the issue.

Tieske commented 2 months ago

@tobil4sk thx for all the digging in this issue!