Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 apt-cacher-ng (3.3.1-2) unstable; urgency=high
 .
   * Fixes FTBFS on mipsel/mips64el
   * Fixes missing last-minute changes in actual upstream version 3.3.1
Author: Eduard Bloch <blade@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2020-01-19

--- apt-cacher-ng-3.3.1.orig/CMakeLists.txt
+++ apt-cacher-ng-3.3.1/CMakeLists.txt
@@ -96,7 +96,26 @@ if(CXX_VIHI)
         _append(ACNG_CXXFLAGS -fvisibility-inlines-hidden)
 endif()
 
-foreach(linkarg -Wl,--as-needed -Wl,-O1 -Wl,--discard-all -Wl,--no-undefined -Wl,--build-id=sha1 -Wl,-fuse-ld=gold)
+option(USE_GOLD "Attempt to use the GOLD linker" ON)
+option(USE_GOLD_MT "Attempt to use the GOLD linker with multi-threading" ON)
+if(${USE_GOLD})
+        if(${USE_GOLD_MT})
+                set(CMAKE_REQUIRED_FLAGS "-Wl,-fuse-ld=gold -Wl,--threads")
+                CHECK_CXX_COMPILER_FLAG("" LD_MULTITHREADED)
+        endif()
+        if(LD_MULTITHREADED)
+                _append(CMAKE_EXE_LINKER_FLAGS "-Wl,-fuse-ld=gold -Wl,--threads")
+        else() # ok, just gold?
+                set(CMAKE_REQUIRED_FLAGS "-Wl,-fuse-ld=gold")
+                CHECK_CXX_COMPILER_FLAG("" LD_GOLD)
+                if(LD_GOLD)
+                        _append(CMAKE_EXE_LINKER_FLAGS "-Wl,-fuse-ld=gold")
+                endif()
+        endif()
+        set(CMAKE_REQUIRED_FLAGS "")
+endif()
+
+foreach(linkarg -Wl,--as-needed -Wl,-O1 -Wl,--discard-all -Wl,--no-undefined -Wl,--build-id=sha1)
 	STRING(REGEX REPLACE "=|-|," "" optname "${linkarg}")
 	set(CMAKE_REQUIRED_FLAGS "${linkarg}")
 	CHECK_CXX_COMPILER_FLAG("" "LD_${optname}")
@@ -106,13 +125,6 @@ foreach(linkarg -Wl,--as-needed -Wl,-O1
 	set(CMAKE_REQUIRED_FLAGS "")
 endforeach(linkarg)
 
-set(CMAKE_REQUIRED_FLAGS "-Wl,-fuse-ld=gold -Wl,--threads")
-CHECK_CXX_COMPILER_FLAG("" LD_MULTITHREADED)
-if(LD_MULTITHREADED)
-	_append(CMAKE_EXE_LINKER_FLAGS "-Wl,-fuse-ld=gold -Wl,--threads")
-endif()
-set(CMAKE_REQUIRED_FLAGS "")
-
 option(USE_SSL "Use OpenSSL library for TLS and other crypto functionality" on)
 
 IF(CMAKE_SYSTEM MATCHES "Darwin")
