changeset 10934:a57d9cc26b5a

8203294: [Linux] Link libgcc and libstdc++ statically to support gcc-7.x Reviewed-by: kcr, mbilla
author arajkumar
date Mon, 28 May 2018 14:24:59 +0530
parents 5a0346b338b6
children 07ee62c2b083
files build.gradle buildSrc/linux.gradle modules/javafx.graphics/src/main/native-glass/gtk/GlassApplication.cpp modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile modules/javafx.media/src/main/native/gstreamer/projects/linux/fxplugins/Makefile modules/javafx.media/src/main/native/gstreamer/projects/linux/gstreamer-lite/Makefile modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile modules/javafx.web/src/main/native/Source/WTF/wtf/PlatformJava.cmake modules/javafx.web/src/main/native/Source/WTF/wtf/StdLibExtras.h modules/javafx.web/src/main/native/Source/cmake/OptionsJava.cmake
diffstat 11 files changed, 42 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/build.gradle	Fri May 25 14:32:47 2018 +0530
+++ b/build.gradle	Mon May 28 14:24:59 2018 +0530
@@ -3725,6 +3725,7 @@
 
     compileTargets { t ->
         def targetProperties = project.rootProject.ext[t.upper]
+        def webkitProperties = targetProperties.webkit
         def classifier = (t.name != "linux" && t.name != "win") ? t.name :
                           IS_64 ? "${t.name}-amd64" : "${t.name}-i586"
 
@@ -3767,12 +3768,19 @@
                     } else if (t.name == "mac") {
                         cmakeArgs = "-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOSX_MIN_VERSION -DCMAKE_OSX_SYSROOT=$MACOSX_SDK_PATH"
                     } else if (t.name == "linux") {
-                        cmakeArgs = "-DCMAKE_SYSTEM_NAME=Linux"
+                        cmakeArgs = "-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_C_COMPILER=${webkitProperties.compiler}"
                         if (IS_64) {
                             cmakeArgs = "$cmakeArgs -DCMAKE_SYSTEM_PROCESSOR=x86_64"
                         } else {
-                            cmakeArgs = "$cmakeArgs -DCMAKE_SYSTEM_PROCESSOR=i586 -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32"
+                            cmakeArgs = "$cmakeArgs -DCMAKE_SYSTEM_PROCESSOR=i586"
                         }
+                        // TODO: Use cflags and ldflags from all platforms
+                        def cFlags = webkitProperties.ccFlags?.join(' ') ?: ''
+                        def lFlags = webkitProperties.linkFlags?.join(' ') ?: ''
+                        // -shared flag should be omitted while creating executable.
+                        def exeFlags = webkitProperties.linkFlags?.join(' ')?.replace('-shared', '') ?: ''
+                        cmakeArgs = "$cmakeArgs -DCMAKE_C_FLAGS='${cFlags}' -DCMAKE_CXX_FLAGS='${cFlags}'"
+                        cmakeArgs = "$cmakeArgs -DCMAKE_SHARED_LINKER_FLAGS='${lFlags}' -DCMAKE_EXE_LINKER_FLAGS='${exeFlags}'"
                     } else if (t.name.startsWith("arm")) {
                         fail("ARM target is not supported as of now.")
                     }
@@ -3820,7 +3828,6 @@
         }
 
         if (IS_WINDOWS && t.name == "win") {
-            def webkitProperties = project.rootProject.ext[t.upper].webkit
             def rcTask = project.task("rc${t.capital}", type: CompileResourceTask) {
                 compiler = webkitProperties.rcCompiler
                 source(webkitProperties.rcSource)
--- a/buildSrc/linux.gradle	Fri May 25 14:32:47 2018 +0530
+++ b/buildSrc/linux.gradle	Mon May 28 14:24:59 2018 +0530
@@ -52,10 +52,12 @@
 // Specify the compilation parameters and link parameters
 def ccFlags = [
         commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c",
+        "-ffunction-sections", "-fdata-sections",
         IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten()
 def ccFlagsGTK3 = ccFlags
 //ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"])
-def linkFlags = ["-shared", commonFlags].flatten()
+def linkFlags = ["-static-libgcc", "-static-libstdc++", "-shared", commonFlags,
+                 "-Wl,--gc-sections"].flatten()
 
 if (IS_DEBUG_NATIVE) {
     linkFlags += "-g"
@@ -268,9 +270,9 @@
 
 LINUX.launcherlibrary = [:]
 LINUX.launcherlibrary.compiler = compiler
-LINUX.launcherlibrary.ccFlags = ["-Wextra", "-Wformat", "-Wformat-security", "-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", "-fPIC", "-std=gnu++98"]
+LINUX.launcherlibrary.ccFlags = ["-Wextra", "-Wformat", "-Wformat-security", "-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", "-fPIC", "-std=gnu++98", "-ffunction-sections", "-fdata-sections"]
 LINUX.launcherlibrary.linker = linker
-LINUX.launcherlibrary.linkFlags = ["-ldl", "-lpthread", "-shared" ]
+LINUX.launcherlibrary.linkFlags = ["-ldl", "-lpthread", "-shared", "-static-libgcc", "-static-libstdc++", "-Wl,--gc-sections"]
 if (!IS_64) {
     LINUX.launcherlibrary.ccFlags += "-m32"
     LINUX.launcherlibrary.linkFlags += "-m32"
@@ -327,3 +329,9 @@
 LINUX.media.compiler = compiler
 LINUX.media.linker = linker
 LINUX.media.ar = "ar"
+
+LINUX.webkit = [:]
+LINUX.webkit.compiler = compiler
+LINUX.webkit.linker = linker
+LINUX.webkit.ccFlags = commonFlags.flatten()
+LINUX.webkit.linkFlags = linkFlags.flatten()
--- a/modules/javafx.graphics/src/main/native-glass/gtk/GlassApplication.cpp	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.graphics/src/main/native-glass/gtk/GlassApplication.cpp	Mon May 28 14:24:59 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 #include <glib.h>
 
 #include <cstdlib>
-#include <iostream>
 #include <com_sun_glass_ui_gtk_GtkApplication.h>
 #include <com_sun_glass_events_WindowEvent.h>
 #include <com_sun_glass_events_MouseEvent.h>
--- a/modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.graphics/src/main/native-glass/gtk/glass_window.cpp	Mon May 28 14:24:59 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,6 @@
 
 #include <string.h>
 
-#include <iostream>
 #include <algorithm>
 
 WindowContext * WindowContextBase::sm_grab_window = NULL;
--- a/modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.media/src/main/native/gstreamer/projects/linux/avplugin/Makefile	Mon May 28 14:24:59 2018 +0530
@@ -27,7 +27,8 @@
          -DHAVE_STDINT_H         \
          -DLINUX                 \
          -DGST_DISABLE_LOADSAVE  \
-         -DGSTREAMER_LITE
+         -DGSTREAMER_LITE \
+         -ffunction-sections -fdata-sections
 
 ifeq ($(BUILD_TYPE), Release)
     CFLAGS += -Os
@@ -46,7 +47,8 @@
 
 LDFLAGS = -L$(BUILD_DIR)    \
           -lgstreamer-lite  \
-           $(PACKAGES_LIBS)
+           $(PACKAGES_LIBS) \
+          -static-libgcc -static-libstdc++ -Wl,--gc-sections
 
 ifneq ($(strip $(LIBAV_DIR)),)
 INCLUDES += -I$(LIBAV_DIR)/include
--- a/modules/javafx.media/src/main/native/gstreamer/projects/linux/fxplugins/Makefile	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.media/src/main/native/gstreamer/projects/linux/fxplugins/Makefile	Mon May 28 14:24:59 2018 +0530
@@ -28,7 +28,8 @@
          -D__MEDIALIB_OLD_NAMES  \
          -DGST_DISABLE_LOADSAVE  \
          -DGST_DISABLE_GST_DEBUG \
-         -DGSTREAMER_LITE
+         -DGSTREAMER_LITE \
+         -ffunction-sections -fdata-sections
 
 ifeq ($(BUILD_TYPE), Release)
     CFLAGS += -Os
@@ -45,7 +46,8 @@
 PACKAGES_INCLUDES := $(shell pkg-config --cflags glib-2.0)
 PACKAGES_LIBS := $(shell pkg-config --libs glib-2.0 gobject-2.0)
 
-LDFLAGS = -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS)
+LDFLAGS = -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS) \
+          -static-libgcc -static-libstdc++ -Wl,--gc-sections
 
 ifeq ($(ARCH), x32)
     CFLAGS += -m32
--- a/modules/javafx.media/src/main/native/gstreamer/projects/linux/gstreamer-lite/Makefile	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.media/src/main/native/gstreamer/projects/linux/gstreamer-lite/Makefile	Mon May 28 14:24:59 2018 +0530
@@ -49,7 +49,8 @@
         -DOUTSIDE_SPEEX         \
         -DLINUX                 \
         -DGST_DISABLE_GST_DEBUG \
-        -DGST_DISABLE_LOADSAVE
+        -DGST_DISABLE_LOADSAVE  \
+        -ffunction-sections -fdata-sections
 
 ifeq ($(BUILD_TYPE), Release)
     CFLAGS += -Os
@@ -73,7 +74,8 @@
 PACKAGES_INCLUDES := $(shell pkg-config --cflags alsa glib-2.0)
 PACKAGES_LIBS := $(shell pkg-config --libs alsa glib-2.0 gobject-2.0 gmodule-2.0 gthread-2.0)
 
-LDFLAGS = -L$(BUILD_DIR) -lm $(PACKAGES_LIBS) 
+LDFLAGS = -L$(BUILD_DIR) -lm $(PACKAGES_LIBS) \
+          -static-libgcc -static-libstdc++ -Wl,--gc-sections
 
 ifeq ($(ARCH), x32)
     CFLAGS += -m32
--- a/modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.media/src/main/native/jfxmedia/projects/linux/Makefile	Mon May 28 14:24:59 2018 +0530
@@ -26,9 +26,9 @@
          -DHAVE_CONFIG_H         \
          -DJFXMEDIA_JNI_EXPORTS  \
          -DLINUX                 \
+         -ffunction-sections -fdata-sections
 
-
-CPPFLAGS = -fno-rtti
+CPPFLAGS = -fno-rtti -ffunction-sections -fdata-sections
 
 BASE_INCLUDES = -I$(SRCBASE_DIR) \
 		-I$(GENERATED_HEADERS_DIR)
@@ -55,7 +55,8 @@
 	           -I$(GSTREAMER_LITE_DIR)/gstreamer/libs \
 		  $(PACKAGES_INCLUDES)
 
-	LDFLAGS = -Wl,-rpath,\$$ORIGIN -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS)
+	LDFLAGS = -Wl,-rpath,\$$ORIGIN -L$(BUILD_DIR) -lgstreamer-lite $(PACKAGES_LIBS) \
+            -static-libgcc -static-libstdc++ -Wl,--gc-sections
 else
 	CFLAGS += $(EXTRA_CFLAGS)
 	INCLUDES = $(BASE_INCLUDES)
--- a/modules/javafx.web/src/main/native/Source/WTF/wtf/PlatformJava.cmake	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.web/src/main/native/Source/WTF/wtf/PlatformJava.cmake	Mon May 28 14:24:59 2018 +0530
@@ -80,6 +80,7 @@
     list(APPEND WTF_INCLUDE_DIRECTORIES
         "${WTF_DIR}/wtf/efl"
     )
+    list(APPEND WTF_LIBRARIES rt)
 elseif (WIN32)
     list(APPEND WTF_SOURCES
         PlatformUserPreferredLanguagesWin.cpp
--- a/modules/javafx.web/src/main/native/Source/WTF/wtf/StdLibExtras.h	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.web/src/main/native/Source/WTF/wtf/StdLibExtras.h	Mon May 28 14:24:59 2018 +0530
@@ -521,7 +521,7 @@
 
 } // namespace std
 
-#if COMPILER(GCC) && GCC_VERSION < 40904
+#if COMPILER(GCC) && GCC_VERSION < 40902
 namespace std {
     template<class T>
         struct is_final
--- a/modules/javafx.web/src/main/native/Source/cmake/OptionsJava.cmake	Fri May 25 14:32:47 2018 +0530
+++ b/modules/javafx.web/src/main/native/Source/cmake/OptionsJava.cmake	Mon May 28 14:24:59 2018 +0530
@@ -107,7 +107,7 @@
 
 elseif(APPLE)
 else()
-    set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-dynamic -static-libstdc++")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-dynamic")
 endif()
 
 WEBKIT_OPTION_BEGIN()