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

Compilation error __NERD_DIRNAME with fib.js, Debian 12 and pre-compiled nerd v0.0.16 #161

Open
mavavilj opened this issue Jan 25, 2024 · 5 comments

Comments

@mavavilj
Copy link

mavavilj commented Jan 25, 2024

node nerd ../fib-main/fib.js

[*] Generating source file
[*] Compiling with preset: speed
[+] Creating Nerd binary lib for std_linux_0.0.16
g++ -std=c++17  -flto -Ofast   -c nerdcore/src/nerd.cpp -o "/home/me/Downloads/nerd-master/.nerd/cached_std_linux_0.0.16/nerd.o"
[+] Compiling with precompiled Nerd lib
/home/me/Downloads/nerd-master/.nerd/uxh7a/fib.cpp: In function ‘int main(int, char**)’:
/home/me/Downloads/nerd-master/.nerd/uxh7a/fib.cpp:77:17: error: ‘__NERD_DIRNAME’ was not declared in this scope
   77 |                 __NERD_DIRNAME = argv_str.substr(0, argv_str.find_last_of("/"));
      |                 ^~~~~~~~~~~~~~
Error: Command failed: g++  -std=c++17 "/home/me/Downloads/nerd-master/.nerd/cached_std_linux_0.0.16/nerd.o" "/home/me/Downloads/nerd-master/.nerd/uxh7a/fib.cpp" -Ofast  -flto -pthread -s   -o "/home/me/Downloads/nerd-master/fib"  
/home/me/Downloads/nerd-master/.nerd/uxh7a/fib.cpp: In function ‘int main(int, char**)’:
/home/me/Downloads/nerd-master/.nerd/uxh7a/fib.cpp:77:17: error: ‘__NERD_DIRNAME’ was not declared in this scope
   77 |                 __NERD_DIRNAME = argv_str.substr(0, argv_str.find_last_of("/"));
      |                 ^~~~~~~~~~~~~~

    at checkExecSyncError (node:child_process:890:11)
    at execSync (node:child_process:962:15)
    at Compiler.Compile (/home/me/Downloads/nerd-master/compiler/native/compiler.js:161:3)
    at /home/me/Downloads/nerd-master/nerd.js:481:13
    at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer >,
    <Buffer 2f 68 6f 6d 65 2f 6d 61 74 74 69 2f 44 6f 77 6e 6c 6f 61 64 73 2f 6e 65 72 64 2d 6d 61 73 74 65 72 2f 2e 6e 65 72 64 2f 75 78 68 37 61 2f 66 69 62 2e ... 294 more bytes>
  ],
  pid: 6703,
  stdout: <Buffer >,
  stderr: <Buffer 2f 68 6f 6d 65 2f 6d 61 74 74 69 2f 44 6f 77 6e 6c 6f 61 64 73 2f 6e 65 72 64 2d 6d 61 73 74 65 72 2f 2e 6e 65 72 64 2f 75 78 68 37 61 2f 66 69 62 2e ... 294 more bytes>
}
[!] Compilation error

fib.js: https://github.com/drujensen/fib

@mavavilj mavavilj changed the title Compilation error with fib.js, Debian 12 and nerd v0.0.16 Compilation error __NERD_DIRNAME with fib.js, Debian 12 and nerd v0.0.16 Jan 25, 2024
@mavavilj
Copy link
Author

mavavilj commented Jan 25, 2024

Not specific to fib.js. Error produced also with, e.g.:

hello.js

// hello world

NOTE:

Possibly the first report of this error, since other Issues seem to be using nectar as opposed to nerd.

@mavavilj mavavilj changed the title Compilation error __NERD_DIRNAME with fib.js, Debian 12 and nerd v0.0.16 Compilation error __NERD_DIRNAME with fib.js, Debian 12 and pre-compiled nerd v0.0.16 Jan 25, 2024
@mavavilj
Copy link
Author

mavavilj commented Jan 25, 2024

Fixable by adding the type std::string to:

__NERD_DIRNAME = argv_str.substr(0, argv_str.find_last_of("/"));

Then the compiler finishes.

@mavavilj
Copy link
Author

Also,

node nerd --run hello.ng
[*] Generating source file
[*] Compiling with preset: speed
lto-wrapper: warning: using serial compilation of 2 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information
../6yng6/nerdcore/src/./class/fixed_array.h: In member function ‘__ct_comp ’:
../6yng6/nerdcore/src/./class/fixed_array.h:50:50: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
   50 |                 value = new NerdCore::VAR[_length];
      |                                                  ^
/usr/include/c++/12/new:128:26: note: in a call to allocation function ‘operator new []’ declared here
  128 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
      |                          ^

[*] Executing /root/Downloads/nerd-master/hello
Hello World !

@adrien-thierry
Copy link
Contributor

could you try with GCC10 or 9 just to check if it comes from GCC ?

@mavavilj
Copy link
Author

mavavilj commented Jan 27, 2024

could you try with GCC10 or 9 just to check if it comes from GCC ?

The __NERD_DIRNAME problem persists, but is fixable as I wrote earlier.

in reply to: #161 (comment)

node ../nerd --run hello.js
[*] Generating source file
[*] Compiling with preset: speed

[*] Executing /root/Downloads/nerd-master/example/hello

I am not an expert on GCC, but to me the programming error at L75 and L77 at

__NERD_DIRNAME = argv_str.substr(0, argv_str.find_last_of("\\"));
looks evident, since L73 is never executed and thus the variable is never initialized.

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

2 participants