-
Notifications
You must be signed in to change notification settings - Fork 22
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
Crash in Clang: Unexpected Xtensa GCC toolchain version (LLVM-160) #56
Comments
Here is a reproducer in Python (adjust paths as needed and make sure #!/usr/bin/env python3
filename = 'foobar.c'
libclangfile = './llvm-build/lib/libclang.so'
from ctypes import *
# Load the .so file
clang = cdll.LoadLibrary(libclangfile)
# Create an index
clang.clang_createIndex.restype = POINTER(c_size_t)
index = clang.clang_createIndex(0, 0)
# Construct command line argument list
args = [filename.encode(), b'--target=xtensa']
argsArrayType = c_char_p * len(args)
argsArray = argsArrayType(*args)
# parse the file
unit = c_void_p()
errCode = clang.clang_parseTranslationUnit2(
index,
None,
argsArray, len(args), # command line args
None, 0, # unsaved files
0, # options
pointer(unit))
if errCode != 0:
raise ValueError('clang_parseTranslationUnit2 returned error code %d' % errCode)
print('successfully parsed', filename) For ARM, it works well:
For Xtensa, it does not:
|
Actually it's way easier: any compilation triggers this bug:
I think it would be more reasonable to continue without a GCC installation instead of crashing. |
Oops, I forgot I was on a different branch: gerekon/xtensa-lld_update (2b94f6d). So I think that branch has a bug, but it's not in the xtensa_release_13.0.0 branch. |
After building LLVM 14 (#57) I found that this bug is present in the xtensa_release_14.0.0 branch:
This is a blocker for LLVM 14 support in TinyGo, unless we drop support for Xtensa. TinyGo doesn't need a GCC installation, we bring our own version of the C standard library for example. |
Hi @aykevl, could I ask you to describe structure of the sysroot directory:
|
Here is the sysroot I'm using: sysroot.zip
The file test.c doesn't really matter, but for completeness here it is: int foo(void) {
return 3;
} The main reason to set the sysroot is for a consistent environment. Include directories (including the include directory in the sysroot) can be manually provided (see tinygo-org/tinygo#2781 for example). |
Hi, @aykevl , thank you for answer. I have a question about "sysroot-picolibc-xtensa-esp32" directory structure. If I understand correctly, usually gcc compiler expects that sysroot directory contains include and lib subdirectories, something like that: |
Hi, @aykevl , please check latest version of the default branch |
Closed by cebbe2d |
I got this crash with assertions enabled:
This is the relevant code:
I did not yet investigate this further or create a small reproducer. Will hopefully do that soon.
The text was updated successfully, but these errors were encountered: