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

Newton lexer error when compiled with clang-14 #613

Open
janithpet opened this issue Aug 1, 2022 · 3 comments
Open

Newton lexer error when compiled with clang-14 #613

janithpet opened this issue Aug 1, 2022 · 3 comments
Assignees
Labels

Comments

@janithpet
Copy link
Collaborator

Describe the bug
After compiling using clang v14, newton produces the following error message when using newton-linux-EN:

newton-lexer.c:151:89: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned long' changed the value to 18446744073709551615 (64-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior newton-lexer.c:151:89 in 
newton-lexer.c:151:26: runtime error: implicit conversion from type '__ssize_t' (aka 'long') of value -1 (64-bit, signed) to type 'uint64_t' (aka 'unsigned long') changed the value to 18446744073709551615 (64-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior newton-lexer.c:151:26 in

To Reproduce
Steps to reproduce the behavior:

  1. Clone repo using git clone --recursive [email protected]:phillipstanleymarbell/Noisy-lang-compiler.git
  2. Create config.local in root directory, and submodules/libflex. config.local looks like:
LIBFLEXPATH=<path-to-repo>/Noisy-lang-compiler/submodules/libflex
CONFIGPATH=<path-to-repo>/home/janith/Noisy-lang-compiler/submodules/libflex
OSTYPE=linux
MACHTYPE=x86_64
  1. Change COMPILERVARIANT = gcc #clang to COMPILERVARIANT = clang in src/common/Makefile, src/newton/Makefile, and submodules/libflex/Makefile.
  2. run make in submodules/libflex.
  3. run make in src/newton.
  4. from src/newton, run newton-linux-EN <any newton file>.

Host OS (please complete the following information):

  • OS: Ubuntu 22.04 LTS (from lsb_release -a)
  • Clang: 14.0.0-1ubuntu1; Target: x86_64-pc-linux-gnu (from clang --version)
  • GCC: 11.2.0-19ubuntu1 (from gcc --version)

Local changes: Base

  • Output of git diff:
diff --git a/src/common/Makefile b/src/common/Makefile
index 416027f4e..7ed6d4144 100755
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -4,7 +4,7 @@ include         $(TREEROOT)/config.local
 
 PRECOMMITHOOK  = precommitStatisticsHook-$(OSTYPE).sh 
 COMMONPATH     = ../common
-COMPILERVARIANT = gcc  #clang
+COMPILERVARIANT = clang
 
 include                $(CONFIGPATH)/config.$(OSTYPE)-$(MACHTYPE).$(COMPILERVARIANT)
 include                config.$(OSTYPE)-$(MACHTYPE).$(COMPILERVARIANT)
diff --git a/src/newton/Makefile b/src/newton/Makefile
index 292acf2bf..c6e1e3c69 100644
--- a/src/newton/Makefile
+++ b/src/newton/Makefile
@@ -9,7 +9,7 @@ NOISYPATH       = ../noisy
 INCLUDEPATH    = ../include
 EXAMPLESPATH   = ../../applications/newton
 
-COMPILERVARIANT = gcc  #clang
+COMPILERVARIANT = clang
 
 LLVM_CONFIG?=llvm-config
 
diff --git a/submodules/libflex b/submodules/libflex
--- a/submodules/libflex
+++ b/submodules/libflex
@@ -1 +1 @@
-Subproject commit d7207627830fc093e4259281b757bdd1305018f6
+Subproject commit d7207627830fc093e4259281b757bdd1305018f6-dirty
  • Output of git remote -v.
origin	[email protected]:phillipstanleymarbell/Noisy-lang-compiler.git (fetch)
origin	[email protected]:phillipstanleymarbell/Noisy-lang-compiler.git (push)

Local changes: libflex

  • Output of git diff:
diff --git a/Makefile b/Makefile
index 89849a2..4b7c4c9 100755
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
 #                make OSTYPE=android MACHTYPE=x86_64 COMPILERVARIANT= WFLAGS=
 #
 include                config.local
-COMPILERVARIANT = gcc  #clang
+COMPILERVARIANT = clang
 include                $(CONFIGPATH)/config.$(OSTYPE)-$(MACHTYPE).$(COMPILERVARIANT)
 
 TARGET         = libflex-$(OSTYPE).a
  • Output of git remote -v:
origin	[email protected]:phillipstanleymarbell/libflex.git (fetch)
origin	[email protected]:phillipstanleymarbell/libflex.git (push)
@janithpet
Copy link
Collaborator Author

janithpet commented Aug 1, 2022

This issue seems to be fixed by changing the version of clang to clang-11, and compiling using gcc.

On the system, I :

  1. ran sudo apt remove clang
  2. ran sudo apt autoremove
  3. ran sudo apt install clang-11
  4. created symbolic links to clang and clang++ from clang-11 and clang++-11 in /usr/bin. The previous step installed the clang tools with the -11 suffix in /usr/bin.
  5. changed the compiler to COMPILEVARIANT = gcc in src/common/Makefile, src/newton/Makefile, and submodules/libflex/Makefile.
  6. reran make (after make clean) in submodules/libflex and src/newton, in that order.

@KomaGR
Copy link
Collaborator

KomaGR commented Aug 1, 2022

This looks like an error that is already happening and is just not getting caught with clang-11. Did you try with clang-12 or clang-13 before clang-11?

@janithpet
Copy link
Collaborator Author

No I didn't, I jumped straight to clang-11.

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

4 participants