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 cross compiling using zig cc #289

Open
alliby opened this issue Jan 10, 2025 · 1 comment
Open

Error when cross compiling using zig cc #289

alliby opened this issue Jan 10, 2025 · 1 comment
Labels

Comments

@alliby
Copy link

alliby commented Jan 10, 2025

i tried to cross compile nelua code from my linux machine to windows using zig cc and mingw
using both these commands

nelua test.nelua --cc="zig cc -target x86-windows"
nelua test.nelua --cc="x86_64-w64-mingw32-gcc"

for this code:

## pragma{nogc=true}
##[[
-- Compile GLAD
--------------------------------------------------
cinclude "glad/glad.h"
cfile "glad/src/glad.c"
cincdir "glad/include"

-- generate bindings for glad
local nldecl = require 'nelua.plugins.nldecl'
if not fs.isfile('glad/init.nelua') then
   nldecl.generate_bindings_file{
      include_dirs = { 'glad/include' },
      output_file = 'glad/init.nelua',
      parse_includes = {'glad/glad.h'},
   }
end
--------------------------------------------------
]]

-- Include GLAD
require "glad"

give the same error for the generated glad bindings:

test.nelua:1:1: from: AST node Block
## pragma{nogc=true}
^~~~~~~~~~~~~~~~~~~~
init.nelua:1:1: from: AST node Block
global gladGLversionStruct: type <cimport,nodecl,ctypedef'gladGLversionStruct'> = @record{
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
init.nelua:7541:8: error: in variable 'INT_FAST16_MAX' declaration: constant value `9223372036854775807` for type `clong` is out of range, the minimum is `-2147483648` and maximum is `2147483647`
global INT_FAST16_MAX: clong <comptime> = 9223372036854775807
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

a workaround for this is manually compiling the generated c code from nelua using the appropriate c compiler

nelua version:

  λ ~ nelua -v
Nelua 0.2.0-dev
Build number: 1629
Git date: 2024-12-14 11:06:09 -0300
Git hash: a69a12d1e1e5ee0bfab299350e5d707ff7b2e744
Semantic version: 0.2.0-dev.1629+a69a12d1
Copyright (C) 2019-2025 Eduardo Bart (https://nelua.io/)

my environment

OS: Void x86_64
Kernel: Linux 6.12.6_3
CPU: 12th Gen Intel(R) Core(TM) i5-1245U (12) @ 4.40 GHz
@alliby alliby added the bug label Jan 10, 2025
@stefanos82
Copy link
Contributor

stefanos82 commented Jan 10, 2025

Your pragma syntax is wrong; here's the correct one: ## pragmas.nogc = true

Actually, I have navigated in Nelua's internals some external libraries and have found this syntax. I have never seen this kind of syntax before.

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

No branches or pull requests

2 participants