make: improve diagnostic messages when the prebuilt tcc executable does not work/is missing

pull/13215/head
Delyan Angelov 2022-01-18 17:25:11 +02:00
parent ef562c92a5
commit 6dfa11e2f7
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 28 additions and 2 deletions

View File

@ -76,7 +76,7 @@ endif
endif endif
endif endif
.PHONY: all clean fresh_vc fresh_tcc .PHONY: all clean fresh_vc fresh_tcc check_for_working_tcc
ifdef prod ifdef prod
VFLAGS+=-prod VFLAGS+=-prod
@ -95,6 +95,7 @@ else
./v2.exe -o $(V) $(VFLAGS) cmd/v ./v2.exe -o $(V) $(VFLAGS) cmd/v
rm -rf v1.exe v2.exe rm -rf v1.exe v2.exe
endif endif
@$(V) run cmd/tools/detect_tcc.v
@echo "V has been successfully built" @echo "V has been successfully built"
@$(V) -version @$(V) -version
@ -110,16 +111,21 @@ latest_vc:
@echo "Using local vc" @echo "Using local vc"
endif endif
check_for_working_tcc:
@$(TMPTCC)/tcc.exe --version > /dev/null 2> /dev/null || echo "The executable '$(TMPTCC)/tcc.exe' does not work."
fresh_vc: fresh_vc:
rm -rf $(VC) rm -rf $(VC)
$(GITFASTCLONE) $(VCREPO) $(VC) $(GITFASTCLONE) $(VCREPO) $(VC)
ifndef local ifndef local
latest_tcc: $(TMPTCC)/.git/config latest_tcc: $(TMPTCC)/.git/config
cd $(TMPTCC) && $(GITCLEANPULL) @pushd . > /dev/null && cd $(TMPTCC) && $(GITCLEANPULL) && popd > /dev/null
@$(MAKE) --quiet check_for_working_tcc 2> /dev/null
else else
latest_tcc: latest_tcc:
@echo "Using local tcc" @echo "Using local tcc"
@$(MAKE) --quiet check_for_working_tcc 2> /dev/null
endif endif
fresh_tcc: fresh_tcc:
@ -128,12 +134,15 @@ ifndef local
# Check wether a TCC branch exists for the user's system configuration. # Check wether a TCC branch exists for the user's system configuration.
ifneq (,$(findstring thirdparty-$(TCCOS)-$(TCCARCH), $(shell git ls-remote --heads $(TCCREPO) | sed 's/^[a-z0-9]*\trefs.heads.//'))) ifneq (,$(findstring thirdparty-$(TCCOS)-$(TCCARCH), $(shell git ls-remote --heads $(TCCREPO) | sed 's/^[a-z0-9]*\trefs.heads.//')))
$(GITFASTCLONE) --branch thirdparty-$(TCCOS)-$(TCCARCH) $(TCCREPO) $(TMPTCC) $(GITFASTCLONE) --branch thirdparty-$(TCCOS)-$(TCCARCH) $(TCCREPO) $(TMPTCC)
@$(MAKE) --quiet check_for_working_tcc 2> /dev/null
else else
@echo 'Pre-built TCC not available for thirdparty-$(TCCOS)-$(TCCARCH) at $(TCCREPO), will use the system compiler: $(CC)' @echo 'Pre-built TCC not available for thirdparty-$(TCCOS)-$(TCCARCH) at $(TCCREPO), will use the system compiler: $(CC)'
$(GITFASTCLONE) --branch thirdparty-unknown-unknown $(TCCREPO) $(TMPTCC) $(GITFASTCLONE) --branch thirdparty-unknown-unknown $(TCCREPO) $(TMPTCC)
@$(MAKE) --quiet check_for_working_tcc 2> /dev/null
endif endif
else else
@echo "Using local tccbin" @echo "Using local tccbin"
@$(MAKE) --quiet check_for_working_tcc 2> /dev/null
endif endif
$(TMPTCC)/.git/config: $(TMPTCC)/.git/config:

View File

@ -9,3 +9,4 @@ all:
./v2 -o v $(VFLAGS) cmd/v ./v2 -o v $(VFLAGS) cmd/v
rm -rf v1 v2 vc/ rm -rf v1 v2 vc/
@echo "V has been successfully built" @echo "V has been successfully built"
./v run ./cmd/tools/detect_tcc.v

View File

@ -0,0 +1,15 @@
fn main() {
$if tinyc {
println('Your `tcc` is working. Good - it is much faster at compiling C source code.')
exit(0)
}
println('
NB: `tcc` was not used, so unless you install it yourself, your backend
C compiler will be `cc`, which is usually either `clang`, `gcc` or `msvc`.
These C compilers, are several times slower at compiling C source code,
compared to `tcc`. They do produce more optimised executables, but that
is done at the cost of compilation speed.
')
}

View File

@ -240,6 +240,7 @@ echo ERROR: please follow the instructions in https://github.com/vlang/v/wiki/In
exit /b 1 exit /b 1
:success :success
.\v.exe run cmd\tools\detect_tcc.v
echo ^> V built successfully! echo ^> V built successfully!
echo ^> To add V to your PATH, run `.\v.exe symlink`. echo ^> To add V to your PATH, run `.\v.exe symlink`.