<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66753>66753</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Environment variable TMP cause “File name too long” warning
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mzyx-hnu
</td>
</tr>
</table>
<pre>
Occurs when compiling kernel perf.
```
2023-09-05 20:09:22 clang-15: error: unable to make temporary file: File name too long
2023-09-05 20:09:22 make[6]: *** [/root/rpmbuild/BUILD/kernel-6.4.0/linux-6.4.0-4.0.0.12.oe2309.aarch64/tools/build/Makefile.build:106: arch/arm64/tests/regs_load.o] Error 1
2023-09-05 20:09:22 make[5]: *** [/root/rpmbuild/BUILD/kernel-6.4.0/linux-6.4.0-4.0.0.12.oe2309.aarch64/tools/build/Makefile.build:140: tests] Error 2
2023-09-05 20:09:22 make[5]: *** Waiting for unfinished jobs....
```
The root cause is kernel tools' makefile does not use TMP environment variable as the temp file path.
```
# kernel/tools/build/Makefile.feature
# FEATURE_TESTS is a long list of feature that will be tested
. . .
feature_display_entries = $(eval $(feature_display_entries_code))
define feature_display_entries_code
ifeq ($(feature_display),1)
$$(info )
$$(info Auto-detecting system features:)
$(foreach feat,$(filter-out $(FEATURE_OMIT),$(FEATURE_DISPLAY)),$(call feature_print_status,$(feat),) $$(info $(MSG)))
endif
ifeq ($(feature_verbose),1)
$(eval TMP := $(filter-out $(FEATURE_DISPLAY),$(FEATURE_TESTS)))
$(foreach feat,$(TMP),$(call feature_print_status,$(feat),) $$(info $(MSG)))
endif
endef
```
llvm will read TMP when creating temp path
```
# llvm/lib/Support/Unix/Path.inc
static const char *getEnvTempDir() {
// Check whether the temporary directory is specified by an environment
// variable.
const char *EnvironmentVariables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
for (const char *Env : EnvironmentVariables) {
if (const char *Dir = std::getenv(Env))
return Dir;
}
return nullptr;
}
```
If TMP variable is initialized for other purpose, llvm will still use it as a temp path. Is this reasonable?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVk-P4rgT_TTmUiIKDgFy4EB3yE8tTWta08xvtaeWSSrE08bO2k73MJ9-VU6A_suu9rBaCYU4qSq_V35VFeGc3GnEJUuvWJqPROcbY5f7X4ef40Z3o62pDsuvZdlZB88NaijNvpVK6h08otWooEVbR8DinMWr4TqLh19Y8pgn4zgbxynwmCWrOGPJinMoldC78SRlyQrQWmPpptNiqxC8gb14RPC4b40V9gC1VEgGhVQIWuzJxoAyend5FwrD0qsZS3NyZ3zV_4AI88Ia4-mv3W87qSrGi6vvN19yxoue3ngWTaOY8UJJ3f3sV-NpFEdxNOGRQZ7EWSSELZvZlPHCG6Mc48Ux2K14REIe9Q-S1SSeEQxyYLwQdt-7ofPkZnHnHpQRVWRYmsOasgKTv0Uw_a8QnBI46BmdOPB_yOE3IT1prTYWOl1LLV2DFfwwWxdFUfSh3vrrpkEg7lCKziFId9TrwGAeNiXoUBl0oI0HMtzc3gHqJ2mN3qP28CSsDJIUDnzTKzKIEVrhm-iC7hlPhj0v5a1G4TuLZ5divdp8_7Z-2KzvN_eEWwSVg5LOg6lhcADfCA_PUinYYkg3Vn2QCCIYcA22D5V0rRKHB9TeSnTAkhwYnzK-wCehhttPjB9KUyHjGf1C0AprqREumgdDAFnjH8D44sMNQszrySkuAPRIyFbq2sCFV6vOm3GFHsugD3dwHvdHTI4lq_e-i9pYFGUTrBi_Hh5K5dGOTecHq2P-v97ebHqIr5_nN_d3X1a_Dxk5vi2FUqeUtFZq_-C88J07bxR27T2yd0Tp9vb-f8eoJ-yoK1m_FNlnSX1CuzUOP01qf9KkbkrO6fw_pf-S5psMBGW-Q3oxy5vbu385W6grrC_0B6We9n35WBRVSEw_3yyKIKlQ6FTjf1HiFCi0zy3jxX3XtsZSw_2u5U_GiztqElKXvT2RlCWURjsPZSMstbod-rV-2u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