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

fix(cli): keep default cc flags in build #3188

Merged
merged 3 commits into from May 5, 2024

Conversation

ObserverOfTime
Copy link
Member

@ObserverOfTime ObserverOfTime commented Mar 17, 2024

Complete commands from CI

i686-unknown-linux-gnu

release

i686-linux-gnu-gcc -O2 -ffunction-sections -fdata-sections -fPIC -m32 -march=i686 -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -DNDEBUG -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

debug

i686-linux-gnu-gcc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-4 -fno-omit-frame-pointer -m32 -march=i686 -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -Wextra -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

powerpc64-unknown-linux-gnu

release

powerpc64-linux-gnu-gcc -O2 -ffunction-sections -fdata-sections -fPIC -m64 -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -DNDEBUG -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

debug

powerpc64-linux-gnu-gcc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-4 -fno-omit-frame-pointer -m64 -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -Wextra -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

arm-unknown-linux-gnueabi

release

arm-linux-gnueabi-gcc -O2 -ffunction-sections -fdata-sections -fPIC -march=armv6 -marm -mfloat-abi=soft -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -DNDEBUG -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

debug

arm-linux-gnueabi-gcc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-4 -fno-omit-frame-pointer -march=armv6 -marm -mfloat-abi=soft -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -Wextra -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

aarch64-unknown-linux-gnu

release

aarch64-linux-gnu-gcc -O2 -ffunction-sections -fdata-sections -fPIC -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -DNDEBUG -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

debug

aarch64-linux-gnu-gcc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-4 -fno-omit-frame-pointer -std=c11 -I /project/test/fixtures/grammars/bash/src -Wall -Wextra -Werror=implicit-function-declaration -shared /project/test/fixtures/grammars/bash/src/parser.c /project/test/fixtures/grammars/bash/src/scanner.c -o /project/parser.so

x86_64-unknown-linux-gnu

release

cc -O2 -ffunction-sections -fdata-sections -fPIC -m64 -std=c11 -I /home/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src -Wall -DNDEBUG -Werror=implicit-function-declaration -shared /home/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/parser.c /home/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/scanner.c -o /home/runner/work/tree-sitter/tree-sitter/parser.so

debug

cc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-4 -fno-omit-frame-pointer -m64 -std=c11 -I /home/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src -Wall -Wextra -Werror=implicit-function-declaration -shared /home/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/parser.c /home/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/scanner.c -o /home/runner/work/tree-sitter/tree-sitter/parser.so

aarch64-apple-darwin

release

cc -O2 -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin -mmacosx-version-min=10.13 -std=c11 -I /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src -Wall -DNDEBUG -Werror=implicit-function-declaration -dynamiclib -UTREE_SITTER_REUSE_ALLOCATOR /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/parser.c /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/scanner.c -o /Users/runner/work/tree-sitter/tree-sitter/parser.dylib

debug

cc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer --target=arm64-apple-darwin -mmacosx-version-min=10.13 -std=c11 -I /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src -Wall -Wextra -Werror=implicit-function-declaration -dynamiclib -UTREE_SITTER_REUSE_ALLOCATOR /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/parser.c /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/scanner.c -o /Users/runner/work/tree-sitter/tree-sitter/parser.dylib

x86_64-apple-darwin

release

cc -O2 -ffunction-sections -fdata-sections -fPIC -m64 --target=x86_64-apple-darwin -mmacosx-version-min=10.13 -std=c11 -I /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src -Wall -DNDEBUG -Werror=implicit-function-declaration -dynamiclib -UTREE_SITTER_REUSE_ALLOCATOR /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/parser.c /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/scanner.c -o /Users/runner/work/tree-sitter/tree-sitter/parser.dylib

debug

cc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-2 -fno-omit-frame-pointer -m64 --target=x86_64-apple-darwin -mmacosx-version-min=10.13 -std=c11 -I /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src -Wall -Wextra -Werror=implicit-function-declaration -dynamiclib -UTREE_SITTER_REUSE_ALLOCATOR /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/parser.c /Users/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/scanner.c -o /Users/runner/work/tree-sitter/tree-sitter/parser.dylib

i686-pc-windows-msvc

release

C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x86\\cl.exe -nologo -MD -O2 -Brepro -std:c11 -I D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src -W4 -DNDEBUG -LD -utf-8 D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\parser.c D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\scanner.c -link -out:D:\\a\\tree-sitter\\tree-sitter\\parser.dll

debug

C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x86\\cl.exe -nologo -MD -Z7 -Brepro -std:c11 -I D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src -W4 -LDd -utf-8 D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\parser.c D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\scanner.c -link -out:D:\\a\\tree-sitter\\tree-sitter\\parser.dll

x86_64-pc-windows-msvc

release

C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x64\\cl.exe -nologo -MD -O2 -Brepro -std:c11 -I D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src -W4 -DNDEBUG -LD -utf-8 D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\parser.c D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\scanner.c -link -out:D:\\a\\tree-sitter\\tree-sitter\\parser.dll

debug

C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX64\\x64\\cl.exe -nologo -MD -Z7 -Brepro -std:c11 -I D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src -W4 -LDd -utf-8 D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\parser.c D:\\a\\tree-sitter\\tree-sitter\\test/fixtures/grammars/bash\\src\\scanner.c -link -out:D:\\a\\tree-sitter\\tree-sitter\\parser.dll

aarch64-pc-windows-msvc

Cannot run in CI

The release / debug variations need #3279

@clason
Copy link
Contributor

clason commented Mar 23, 2024

Further requests one might fold into this:

  • create directories if not existing (i.e., ts b -o foo/bar.so)
  • call ts g if parser.c doesn't exist
  • output parity for make and ts b

@clason
Copy link
Contributor

clason commented Mar 26, 2024

Out of interest (and for the sake of documentation): what flags are used by default (esp. -O)?

@ObserverOfTime
Copy link
Member Author

  • create directories if not existing (i.e., ts b -o foo/bar.so)
  • call ts g if parser.c doesn't exist

Those are beyond my capabilities.

  • output parity for make and ts b

We don't necessarily want that.
ts b is an easy and cross-platform way to build the parser.
make is mostly meant to be used in distro packages, which have their own preferred flags.

@ObserverOfTime
Copy link
Member Author

ObserverOfTime commented Mar 26, 2024

Windows and macOS builds fail when TREE_SITTER_REUSE_ALLOCATOR is set. Maybe we need TS_PUBLIC again? 🤔

Nevermind, I think the parsers are just outdated.

@clason
Copy link
Contributor

clason commented Mar 26, 2024

I think we do. If distro packages need their own flags, they will write their own build scripts

@ObserverOfTime
Copy link
Member Author

I think we do. If distro packages need their own flags, they will write their own build scripts

The required flags will still be the same.

@ObserverOfTime
Copy link
Member Author

ObserverOfTime commented Mar 26, 2024

Out of interest (and for the sake of documentation): what flags are used by default (esp. -O)?

The release build uses -O2 and the debug build uses -O0.

CFLAGS are applied after the -std flag.
-mmacosx-version-min is controlled by MACOSX_DEPLOYMENT_TARGET.

@ObserverOfTime
Copy link
Member Author

/home/runner/work/tree-sitter/tree-sitter/test/fixtures/grammars/bash/src/scanner.c:113:9: runtime error: null pointer passed as argument 2, which is declared to never be null

Adding assert(heredoc->delimiter.contents != NULL); before that line should silence UBSAN. @amaanq

@clason
Copy link
Contributor

clason commented Mar 26, 2024

Would be good to document that somewhere, as a reference.

(nvim-treesitter/makefile uses -Os, but I don't see much difference in size)

@ObserverOfTime
Copy link
Member Author

ObserverOfTime commented Mar 26, 2024

Would be good to document that somewhere, as a reference.

I think the default flags are too complicated to document and not that important.
We can always point here if anyone asks.

@amaanq amaanq merged commit 572cdaa into tree-sitter:master May 5, 2024
12 checks passed
@ObserverOfTime ObserverOfTime deleted the build branch May 5, 2024 19:38
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

Successfully merging this pull request may close these issues.

Nonstandard builds using CLI
3 participants