From 81374c774e3e20dfc74a3f9c39e540010a606daa Mon Sep 17 00:00:00 2001 From: Seb M'Caw Date: Thu, 13 Feb 2025 11:19:12 +0000 Subject: [PATCH] fix: remove `libgcc_s_seh-1.dll` dependency (#1847) * Add test * Add '-static' linker switch --- alire_common.gpr | 8 +++++++ alr.gpr | 1 + testsuite/tests/misc/empty-path/test.py | 26 +++++++++++++++++++++++ testsuite/tests/misc/empty-path/test.yaml | 1 + 4 files changed, 36 insertions(+) create mode 100644 testsuite/tests/misc/empty-path/test.py create mode 100644 testsuite/tests/misc/empty-path/test.yaml diff --git a/alire_common.gpr b/alire_common.gpr index fe88657b..ed3281ee 100644 --- a/alire_common.gpr +++ b/alire_common.gpr @@ -132,6 +132,14 @@ abstract project Alire_Common is ); end Binder; + package Linker is + case Host_OS is + -- Link statically on Windows to avoid DLL dependencies + when "windows" => for Switches ("Ada") use ("-static"); + when others => null; + end case; + end Linker; + package Ide is for Vcs_Kind use "Git"; end Ide; diff --git a/alr.gpr b/alr.gpr index 00620f5d..c55c0060 100644 --- a/alr.gpr +++ b/alr.gpr @@ -36,6 +36,7 @@ project Alr is end Builder; package Binder renames Alire_Common.Binder; + package Linker renames Alire_Common.Linker; package Ide renames Alire_Common.Ide; end Alr; diff --git a/testsuite/tests/misc/empty-path/test.py b/testsuite/tests/misc/empty-path/test.py new file mode 100644 index 00000000..900ff16f --- /dev/null +++ b/testsuite/tests/misc/empty-path/test.py @@ -0,0 +1,26 @@ +""" +Verify that `alr` doesn't depend on anything being on `PATH` for basic commands +(e.g. `.dll` files on Windows). +""" + + +import os +from drivers.alr import run_alr + + +# Check `alr --version` succeeds and prints something. +p = run_alr("--version") +assert len(p.out) > 0 + +# Completely clear `PATH`. +# +# Setting it to an empty string causes a buffer overflow on some platforms +# so we set it to a nonexistent directory. +os.environ["PATH"] = os.path.join(os.getcwd(), "nonexistent") + +# Check `alr --version` still succeeds and prints something. +p = run_alr("--version") +assert len(p.out) > 0 + + +print("SUCCESS") diff --git a/testsuite/tests/misc/empty-path/test.yaml b/testsuite/tests/misc/empty-path/test.yaml new file mode 100644 index 00000000..32c747b3 --- /dev/null +++ b/testsuite/tests/misc/empty-path/test.yaml @@ -0,0 +1 @@ +driver: python-script -- 2.39.5