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

Add version.h defining WASI_LIBC_VERSION #534

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ endif

BUILTINS_LIB ?= $(shell ${CC} ${CFLAGS} --print-libgcc-file-name)

LIBC_GIT_REF := $(shell git describe --tags --dirty)

# These variables describe the locations of various files and directories in
# the source tree.
DLMALLOC_DIR = dlmalloc
Expand Down Expand Up @@ -771,6 +773,12 @@ include_dirs:
mkdir -p "$(SYSROOT_INC)"
cp -r "$(LIBC_BOTTOM_HALF_HEADERS_PUBLIC)"/* "$(SYSROOT_INC)"

# Generate the version.h header (and remove the template).
rm -f "$(SYSROOT_INC)/wasi/version.h.in"
sed 's/{{VERSION}}/$(LIBC_GIT_REF)/' \
$(LIBC_BOTTOM_HALF_HEADERS_PUBLIC)/wasi/version.h.in \
> "$(SYSROOT_INC)/wasi/version.h"

# Generate musl's bits/alltypes.h header.
mkdir -p "$(SYSROOT_INC)/bits"
sed -f $(LIBC_TOP_HALF_MUSL_DIR)/tools/mkalltypes.sed \
Expand Down Expand Up @@ -973,6 +981,7 @@ check-symbols: startup_files libc
| grep -v '^#define __OPTIMIZE__' \
| grep -v '^#define assert' \
| grep -v '^#define __NO_INLINE__' \
| grep -v '^#define WASI_LIBC_VERSION' \
> "$(SYSROOT_SHARE)/predefined-macros.txt"

# Check that the computed metadata matches the expected metadata.
Expand Down
1 change: 1 addition & 0 deletions expected/wasm32-wasip1-threads/include-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,6 @@
#include <wasi/libc-find-relpath.h>
#include <wasi/libc-nocwd.h>
#include <wasi/libc.h>
#include <wasi/version.h>
#include <wchar.h>
#include <wctype.h>
1 change: 1 addition & 0 deletions expected/wasm32-wasip1-threads/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,7 @@
#define USHRT_MAX 0xffff
#define UTIME_NOW (-1)
#define UTIME_OMIT (-2)
#define VERSION_H
#define WCHAR_MAX (0x7fffffff+L'\0')
#define WCHAR_MIN (-1-0x7fffffff+L'\0')
#define WEOF 0xffffffffU
Expand Down
1 change: 1 addition & 0 deletions expected/wasm32-wasip1/include-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,6 @@
#include <wasi/libc-find-relpath.h>
#include <wasi/libc-nocwd.h>
#include <wasi/libc.h>
#include <wasi/version.h>
#include <wchar.h>
#include <wctype.h>
1 change: 1 addition & 0 deletions expected/wasm32-wasip1/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,7 @@
#define USHRT_MAX 0xffff
#define UTIME_NOW (-1)
#define UTIME_OMIT (-2)
#define VERSION_H
#define WCHAR_MAX (0x7fffffff+L'\0')
#define WCHAR_MIN (-1-0x7fffffff+L'\0')
#define WEOF 0xffffffffU
Expand Down
1 change: 1 addition & 0 deletions expected/wasm32-wasip2/include-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
#include <wasi/libc-find-relpath.h>
#include <wasi/libc-nocwd.h>
#include <wasi/libc.h>
#include <wasi/version.h>
#include <wasi/wasip2.h>
#include <wchar.h>
#include <wctype.h>
1 change: 1 addition & 0 deletions expected/wasm32-wasip2/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2139,6 +2139,7 @@
#define USHRT_MAX 0xffff
#define UTIME_NOW (-1)
#define UTIME_OMIT (-2)
#define VERSION_H
#define WCHAR_MAX (0x7fffffff+L'\0')
#define WCHAR_MIN (-1-0x7fffffff+L'\0')
#define WEOF 0xffffffffU
Expand Down
5 changes: 5 additions & 0 deletions libc-bottom-half/headers/public/wasi/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Generated by wasi-lib's `Makefile`.
#ifndef VERSION_H
#define VERSION_H
#define WASI_LIBC_VERSION "{{VERSION}}"
#endif