Skip to content

Clang support#102

Open
remexre wants to merge 35 commits into
trunkfrom
remexre/clang-support
Open

Clang support#102
remexre wants to merge 35 commits into
trunkfrom
remexre/clang-support

Conversation

@remexre
Copy link
Copy Markdown
Member

@remexre remexre commented Apr 9, 2026

Resolves #79.
Supersedes #84.

Comment thread .github/workflows/build.yml Outdated
tar \
zstd
zstd \
clang
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetical order

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in b9e7c2c

Comment thread .github/workflows/build.yml Outdated
cd build
../configure --target ${{ matrix.target }}
export target=${{ matrix.target }}
[[ ${{ matrix.target }} == *"clang" ]] && ../configure --target ${target::-6} --clang || ../configure --target ${{ matrix.target }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[[ ${{ matrix.target }} == *"clang" ]] && ../configure --target ${target::-6} --clang || ../configure --target ${{ matrix.target }}
if [[ ${{ matrix.target }} == *"clang" ]]; then
../configure --target ${target::-6} --clang
else
../configure --target ${{ matrix.target }}
fi

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in b9e7c2c

#include <types.h>

[[gnu::access(write_only, 1), gnu::nonnull(1)]]
[[gnu::nonnull(1)]]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should access write only be removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ce83c26

/**
* Like `alloc`, but only for allocations with `0 < size && size <= 1024`.
*/
[[gnu::alloc_size(1), gnu::malloc, gnu::malloc(free, 1), nodiscard]] void *
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this have been removed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8aca21d

Comment thread configure Outdated
printf >&2 'Defaults for the options are specified in brackets.\n'
printf >&2 '\nSystem:\n'
printf >&2 ' --arch=ARCH build for the given architecture [%s]\n' "$arch"
printf >&2 ' --clang build with clang instead of gcc\n'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf >&2 ' --clang build with clang instead of gcc\n'
printf >&2 ' --clang build with Clang instead of GCC\n'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in b9e7c2c

Comment thread configure

# Add default CFLAGS and LDFLAGS.
if [[ "$default_cflags" = 1 ]]; then
CFLAGS="-g -O3 -Wall -Werror ${CFLAGS:-}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undo

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d7783ba.

Comment thread configure Outdated
if [[ "$clang" == 1 ]]; then
CC="clang"
find_tool_with_prefix CC clang
CFLAGS="-target riscv64-none-elf -std=c23 $CFLAGS"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look into -std=c23

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in b9e7c2c

@remexre remexre force-pushed the remexre/clang-support branch 3 times, most recently from 2972a07 to f023525 Compare April 25, 2026 14:52
june-fish and others added 26 commits April 25, 2026 09:53
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: junefish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: june-fish <git@june.fish>
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
Honestly, I could kinda feel moving these out to a separate .c file, so
we could then more easily test that they match the GCC builtins (at
least on u8, u16, and u32)...

We could probably rely on LTO for performance with Clang, in that case.

Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
remexre added 8 commits April 25, 2026 09:53
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
This gets a warning on GCC; if the function gets inlined anyway, we
inherit that attribute from alloc(), I suppose.

Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
Signed-off-by: Amy Ringo <me@remexre.com>
The latter is for functions that're always incorrect when discarded; the
former is a lot easier to silence.

Signed-off-by: Amy Ringo <me@remexre.com>
@remexre remexre force-pushed the remexre/clang-support branch from f023525 to aadac28 Compare April 25, 2026 14:53
@remexre remexre mentioned this pull request Apr 25, 2026
Signed-off-by: Amy Ringo <me@remexre.com>
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.

Clang support

3 participants