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 flag #61

Merged
merged 20 commits into from
Sep 10, 2023
Merged

Add --version flag #61

merged 20 commits into from
Sep 10, 2023

Conversation

AngheloAlf
Copy link
Contributor

Adds a --version flag to every recomped program.

Passing this flag to a program makes it print version information and exit immediately . Example:

$ ./cc --version
IDO 7.1 `cc` static recompilation, Decompals version
Source:     https://github.com/decompals/ido-static-recomp
Version:    v0.6-20-gc47487d
Build date: 2023-09-10 18:07:59 UTC+0000
Compiler:   GCC 9.4.0

@AngheloAlf
Copy link
Contributor Author

Closes #45

Comment on lines +276 to +280
$(BUILD_DIR)/arm64-apple-macos11/$(VERSION_INFO).o: $(VERSION_INFO).c $(O_FILES) $(BUILD_DIR)/arm64-apple-macos11/$(LIBC_IMPL).o
$(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) -D$(IDO_VERSION) $(WARNINGS) -target arm64-apple-macos11 -o $@ $<

$(BUILD_DIR)/x86_64-apple-macos10.14/$(VERSION_INFO).o: $(VERSION_INFO).c $(O_FILES) $(BUILD_DIR)/x86_64-apple-macos10.14/$(LIBC_IMPL).o
$(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) -D$(IDO_VERSION) $(WARNINGS) -target x86_64-apple-macos10.14 -o $@ $<
Copy link
Contributor

Choose a reason for hiding this comment

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

These shouldn't need to depend on other .o files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Elliptic's intention here was to force a rebuild for the version_info.o files if any other file was touched, so the version is always up to date.
Do you have a better way to handle this?

Copy link
Contributor

@simonlindholm simonlindholm Sep 10, 2023

Choose a reason for hiding this comment

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

Oh, right! Makes sense, worth a comment maybe

@@ -292,8 +303,19 @@ $(BUILD_DIR)/$(LIBC_IMPL).o: $(LIBC_IMPL).c

$(BUILD_DIR)/$(LIBC_IMPL)_53.o: $(LIBC_IMPL).c
$(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) -DIDO53 $(WARNINGS) -o $@ $<

$(BUILD_DIR)/$(VERSION_INFO).o: $(VERSION_INFO).c $(O_FILES) $(BUILD_DIR)/$(LIBC_IMPL).o $(BUILD_DIR)/$(LIBC_IMPL)_53.o
Copy link
Contributor

Choose a reason for hiding this comment

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

similarly

cp $^ $@

$(BUILD_BASE)/7.1/x86_64-apple-macos10.14/NCC: $(BUILD_BASE)/7.1/x86_64-apple-macos10.14/cc
cp $^ $@
Copy link
Contributor

Choose a reason for hiding this comment

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

what happened to these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

version_info.o depends on every other .o file to be built first, but we weren't creating NCC.c/NCC.o files because this file is just a renamed cc binary. Because of this make couldn't build the version_info.o file, so how NCC is handled, instead of copying and renaming a cc program, it copies the cc.c program and builds that instead

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, ok. Seems a bit wasteful to compile cc.c multiple times, maybe the .o can be copied instead. Or NCC can be filtered out from O_FILES.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding an empty rule for NCC.o still complains because the other rule already set the dependency of NCC.o on NCC.c
I'll try to filter it out from O_FILES

version_info.c Outdated Show resolved Hide resolved
version_info.c Outdated Show resolved Hide resolved
version_info.c Outdated Show resolved Hide resolved
version_info.c Outdated Show resolved Hide resolved
AngheloAlf and others added 6 commits September 10, 2023 16:05
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
Co-authored-by: Simon Lindholm <simon.lindholm10@gmail.com>
Copy link
Contributor

@hensldm hensldm left a comment

Choose a reason for hiding this comment

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

1 Small nit

.github/workflows/build.yml Outdated Show resolved Hide resolved
Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
@ethteck
Copy link
Member

ethteck commented Sep 10, 2023

1 mall snit
edit: lost the snit. carry on

@hensldm hensldm merged commit 48b3c00 into master Sep 10, 2023
12 checks passed
@ethteck ethteck deleted the versioning branch September 10, 2023 19:44
@hensldm hensldm mentioned this pull request Sep 11, 2023
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.

5 participants