Add -Wl,--no-as-needed to ld flags

Older version of gcc mistakenly missed out on linking libdl without it.

Change-Id: I5c12972c140348fa504e4ff4acb81655b445b4a5
Reviewed-on: https://swiftshader-review.googlesource.com/c/24268
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cb417fd..ee373b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -156,6 +156,11 @@
         if(NOT MSAN AND NOT ASAN AND NOT TSAN AND NOT UBSAN)
             set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined")
         endif()
+
+        # Older version of GCC have problem linking libdl when --as-needed is set.
+        if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
+            set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-as-needed")
+        endif()
     endif()
 endmacro()
 
diff --git a/kokoro/gcp_ubuntu/continuous.sh b/kokoro/gcp_ubuntu/continuous.sh
index 4caf6ce..e1c5bc7 100755
--- a/kokoro/gcp_ubuntu/continuous.sh
+++ b/kokoro/gcp_ubuntu/continuous.sh
@@ -12,4 +12,4 @@
 mkdir -p build && cd build
 
 cmake ..
-make --jobs=$(nproc)
+make --jobs=$(nproc) VERBOSE=1