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

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

Closed
Ryuu-64 opened this issue Jul 4, 2024 · 18 comments · Fixed by #32
Closed

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

Ryuu-64 opened this issue Jul 4, 2024 · 18 comments · Fixed by #32

Comments

@Ryuu-64
Copy link

Ryuu-64 commented Jul 4, 2024

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
Copy link
Member

Tieske commented Jul 4, 2024

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

@Ryuu-64
Copy link
Author

Ryuu-64 commented Jul 9, 2024

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
Copy link
Member

Tieske commented Jul 9, 2024

what windows version are you on?

@Tieske
Copy link
Member

Tieske commented Jul 9, 2024

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
Copy link

tobil4sk commented Jul 18, 2024

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
Copy link
Member

Tieske commented Jul 19, 2024

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
Copy link

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:

luasystem/src/term.c

Lines 106 to 108 in 4549924

// Define a macro to check if a constant is defined and set it to 0 if not.
// This is needed because some flags are not defined on all platforms. So we
// still export the constants, but they will be all 0, and hence not do anything.

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
Copy link
Member

Tieske commented Jul 20, 2024

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
Copy link
Contributor

o-lim commented Jul 20, 2024

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
Copy link
Member

Tieske commented Jul 20, 2024

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
Copy link
Contributor

o-lim commented Jul 20, 2024

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
Copy link
Member

Tieske commented Jul 21, 2024

@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
Copy link
Author

Ryuu-64 commented Jul 22, 2024

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
Copy link
Author

Ryuu-64 commented Jul 22, 2024

@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
Copy link
Member

Tieske commented Jul 22, 2024

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
Copy link

tobil4sk commented Jul 26, 2024

@Ryuu-64 @tobil4sk would you mind giving #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: actions/runner-images#10352

@tobil4sk
Copy link

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
Copy link
Member

Tieske commented Jul 29, 2024

@tobil4sk thx for all the digging in this issue!

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

Successfully merging a pull request may close this issue.

4 participants