Skip to content

Commit a2798b3

Browse files
committed
fix(port): fix bad reference to 'environ' global
We forward-declare 'environ' on Linux. However, our forward declaration is inside a namespace, and that seems to cause problems on Arch Linux now: ``` /usr/sbin/ld: ../src/libquick-lint-js-lib.a(child-process.cpp.o): warning: relocation against `_ZN13quick_lint_js12_GLOBAL__N_17environE' in read-only section `.text._ZN13quick_lint_js12_GLOBAL__N_1L21get_posix_environmentEv' /usr/sbin/ld: ../src/libquick-lint-js-lib.a(child-process.cpp.o): in function `quick_lint_js::(anonymous namespace)::get_posix_environment()': /__w/quick-lint-js/quick-lint-js/src/quick-lint-js/port/child-process.cpp:364:(.text._ZN13quick_lint_js12_GLOBAL__N_1L21get_posix_environmentEv+0x7): undefined reference to `quick_lint_js::(anonymous namespace)::environ' /usr/sbin/ld: warning: creating DT_TEXTREL in a PIE collect2: error: ld returned 1 exit status ``` Fix this issue by moving the forward declaration of 'environ' out of a namespace.
1 parent e285f0e commit a2798b3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/quick-lint-js/port/child-process.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242

4343
using namespace std::literals::string_view_literals;
4444

45+
#if QLJS_HAVE_UNISTD_H && !QLJS_HAVE_NS_GET_ENVIRON
46+
extern "C" char** environ;
47+
#endif
48+
4549
namespace quick_lint_js {
4650
namespace {
4751
#if QLJS_HAVE_UNISTD_H
@@ -353,10 +357,6 @@ Run_Program_Result run_program(Span<const char* const> command,
353357

354358
namespace {
355359
#if QLJS_HAVE_UNISTD_H
356-
#if !QLJS_HAVE_NS_GET_ENVIRON
357-
extern "C" char** environ;
358-
#endif
359-
360360
char** get_posix_environment() {
361361
#if QLJS_HAVE_NS_GET_ENVIRON
362362
return *::_NSGetEnviron();

0 commit comments

Comments
 (0)