Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link error "undefined hidden symbol:" in firefox 93 building with clang #37

Closed
smsxgli opened this issue Oct 20, 2021 · 12 comments
Closed

Comments

@smsxgli
Copy link

smsxgli commented Oct 20, 2021

I am a KDE user, build firefox 93 with these patches. While during linking libxul.so, the lld failed with error

ld.lld: error: undefined hidden symbol: nsKDEShellService::IsDefaultForScheme(nsTSubstring<char> const&, bool*)
>>> referenced by nsKDEShellService.cpp
>>>               /build/firefox-kde-opensuse/src/firefox-93.0/obj/toolkit/library/build/../../../browser/components/shell/nsKDEShellService.o:(vtable for nsKDEShellService)

I think this might because of the unimplemented virtual function IsDefaultForScheme, which should be defined in browser/components/shell/nsKDEShellService.cpp, created by the firefox-kde.patch file.

I try to fix this error by offering the missing function with just return NS_ERROR_NOT_IMPLEMENTED, and then this error is gone. But I have no idea about how to really realize this function.

Build environment:
Arch linux, amd64
Build with clang, llvm and lld, version12

If any more information should be offered, please let me known, and forgive my poor english since I'm not a native speaker.

@francoism90
Copy link

francoism90 commented Oct 23, 2021

@smsxgli Did you ever solved this? :)

@smsxgli
Copy link
Author

smsxgli commented Oct 23, 2021

I solved this link error by the ugly hack I mentioned above, but the llvm throw another error during PGO, LLVM ERROR: Cannot select: intrinsic %llvm.x86.aesni.aesenc, after googling, someone said it's caused by thin lto, but with lto, the lld eat more than 40G memory, while my machine has only 32G RAM, so I'm trying turn to building with GCC now. By the way, this LLVM error also apear when I build firefox with the official PKGBUILD.

@francoism90
Copy link

@smsxgli Could you please provide your hack/workaround? :)

It does build firefox-developer-edition without OpenSUSE patches:
AMD 3600 + 16GB + 8GB provided by zram.

It helps closing things eating CPU and memory like badoo, dolphin and the browser.

@francoism90
Copy link

@smsxgli You can view my current testing sources here:

https://github.com/francoism90/pkgs/tree/master/firefox-dev-kde-opensuse

@smsxgli
Copy link
Author

smsxgli commented Oct 23, 2021

@francoism90 Do you have the same issue? If so, I'am happy to offer the modified patch. Since I have no idea about how to upload a patch file here, I will post it as plain text.
And I build successfully with GCC and KDE's patches.
Edit: Delete the mistack patch, it's same with original one

@francoism90
Copy link

francoism90 commented Oct 23, 2021

@smsxgli Do you have repository containing the full set (incl. PKGBUILD, mozconfig, etc.)? :)

I'll try to checkout your patch, thanks!

Edit: this does seem to be the same provided patch here?

@smsxgli
Copy link
Author

smsxgli commented Oct 23, 2021

@francoism90 Thanks, I will have a test on your PKGBUILD. In fact, I just used firefox-branded-icons.patch, firefox-kde.patch, mozilla-kde.patch, mozilla-nongnome-proxies.patch, mozilla-silence-no-return-type.patch these patches from KDE, and others from Arch official, Gentoo and LibreWolf.

@smsxgli
Copy link
Author

smsxgli commented Oct 23, 2021

@francoism90 Oh, yes, I mess something up, really sorry for that. Now I will test my patch again. Really strange. I will test on your PKGBUILD.

@smsxgli
Copy link
Author

smsxgli commented Oct 23, 2021

@francoism90 You can test with this patch, it should work, if my memory do not lie to me...

# HG changeset patch
# User msirringhaus@suse.de
# Date 1559300151 -7200
#      Fri May 31 12:55:51 2019 +0200
# Node ID 54d41b0033b8d649d842a1f862c6fed8b9874dec
# Parent  856ef9c699423b1cd35e4df8745e78c409c8dbae
How to apply this patch:
1. Import and apply it
2. cp browser/base/content/browser.xul browser/base/content/browser-kde.xul
3. Find editBookmarkPanelDoneButton
4. Replace #ifndef with #ifdef in the line above (this hanges the button order from Gnome-style to KDE-style)
5. hg qrefresh

diff --git a/browser/components/preferences/main.js b/browser/components/preferences/main.js
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
@@ -338,16 +338,23 @@ var gMainPane = {
         }, backoffTimes[this._backoffIndex + 1 < backoffTimes.length ? this._backoffIndex++ : backoffTimes.length - 1]);
       };
 
       window.setTimeout(() => {
         window.requestIdleCallback(pollForDefaultBrowser);
       }, backoffTimes[this._backoffIndex]);
     }
 
+    var env = Components.classes["@mozilla.org/process/environment;1"]
+      .getService(Components.interfaces.nsIEnvironment);
+    var kde_session = 0;
+    if (env.get('KDE_FULL_SESSION') == "true") {
+      kde_session = 1;
+    }
+
     this.initBrowserContainers();
     this.buildContentProcessCountMenuList();
 
     let performanceSettingsLink = document.getElementById(
       "performanceSettingsLearnMore"
     );
     let performanceSettingsUrl =
       Services.urlFormatter.formatURLPref("app.support.baseURL") +
@@ -1313,16 +1320,27 @@ var gMainPane = {
       this._backoffIndex = 0;
 
       let shellSvc = getShellService();
       if (!shellSvc) {
         return;
       }
       try {
         shellSvc.setDefaultBrowser(true, false);
+        if (kde_session == 1) {
+          var shellObj = Components.classes["@mozilla.org/file/local;1"]
+            .createInstance(Components.interfaces.nsILocalFile);
+          shellObj.initWithPath("/usr/bin/kwriteconfig");
+          var process = Components.classes["@mozilla.org/process/util;1"]
+            .createInstance(Components.interfaces.nsIProcess);
+          process.init(shellObj);
+          var args = ["--file", "kdeglobals", "--group", "General", "--key",
+              "BrowserApplication", "firefox"];
+          process.run(false, args, args.length);
+        }
       } catch (ex) {
         Cu.reportError(ex);
         return;
       }
 
       let isDefault = shellSvc.isDefaultBrowser(false, true);
       let setDefaultPane = document.getElementById("setDefaultPane");
       setDefaultPane.classList.toggle("is-default", isDefault);
diff --git a/browser/components/shell/moz.build b/browser/components/shell/moz.build
--- a/browser/components/shell/moz.build
+++ b/browser/components/shell/moz.build
@@ -32,16 +32,18 @@ if CONFIG["MOZ_WIDGET_TOOLKIT"] == "coco
     ]
 elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
     XPIDL_SOURCES += [
         "nsIGNOMEShellService.idl",
     ]
 
     SOURCES += [
         "nsGNOMEShellService.cpp",
+        "nsKDEShellService.cpp",
+        "nsUnixShellService.cpp",
     ]
     if CONFIG["MOZ_ENABLE_DBUS"]:
         SOURCES += [
             "nsGNOMEShellDBusHelper.cpp",
             "nsGNOMEShellSearchProvider.cpp",
         ]
         include("/ipc/chromium/chromium-config.mozbuild")
 
diff --git a/browser/components/shell/nsKDEShellService.cpp b/browser/components/shell/nsKDEShellService.cpp
new file mode 100644
--- /dev/null
+++ b/browser/components/shell/nsKDEShellService.cpp
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/ArrayUtils.h"
+
+#include "nsCOMPtr.h"
+#include "nsKDEShellService.h"
+#include "nsShellService.h"
+#include "nsKDEUtils.h"
+#include "nsIPrefService.h"
+#include "nsIProcess.h"
+#include "nsIFile.h"
+#include "nsServiceManagerUtils.h"
+#include "nsComponentManagerUtils.h"
+#include "nsIMutableArray.h"
+#include "nsISupportsPrimitives.h"
+#include "nsArrayUtils.h"
+
+using namespace mozilla;
+
+nsresult
+nsKDEShellService::Init()
+{
+    if( !nsKDEUtils::kdeSupport())
+        return NS_ERROR_NOT_AVAILABLE;
+    return NS_OK;
+}
+
+NS_IMPL_ISUPPORTS(nsKDEShellService, nsIGNOMEShellService, nsIShellService)
+
+NS_IMETHODIMP
+nsKDEShellService::IsDefaultBrowser(bool aForAllTypes,
+                                    bool* aIsDefaultBrowser)
+{
+    *aIsDefaultBrowser = false;
+
+    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
+    if (!command)
+        return NS_ERROR_FAILURE;
+
+    nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
+    if (!str)
+        return NS_ERROR_FAILURE;
+
+    str->SetData("ISDEFAULTBROWSER"_ns);
+    command->AppendElement( str );
+
+    if( nsKDEUtils::command( command ))
+        *aIsDefaultBrowser = true;
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+nsKDEShellService::SetDefaultBrowser(bool aClaimAllTypes,
+                                     bool aForAllUsers)
+{
+    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
+    if (!command)
+        return NS_ERROR_FAILURE;
+
+    nsCOMPtr<nsISupportsCString> cmdstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
+    nsCOMPtr<nsISupportsCString> paramstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
+    if (!cmdstr || !paramstr)
+        return NS_ERROR_FAILURE;
+
+    cmdstr->SetData("SETDEFAULTBROWSER"_ns);
+    command->AppendElement( cmdstr );
+
+    paramstr->SetData( aClaimAllTypes ? "ALLTYPES"_ns : "NORMAL"_ns );
+    command->AppendElement( paramstr );
+
+    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+nsKDEShellService::GetCanSetDesktopBackground(bool* aResult)
+{
+  *aResult = true;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsKDEShellService::SetDesktopBackground(dom::Element* aElement,
+                                        int32_t aPosition,
+                                        const nsACString& aImageName)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsKDEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsKDEShellService::IsDefaultForScheme(nsTSubstring<char> const& aScheme, 
+                                      bool* aIsDefaultBrowser)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsKDEShellService::SetDesktopBackgroundColor(PRUint32 aColor)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+
diff --git a/browser/components/shell/nsKDEShellService.h b/browser/components/shell/nsKDEShellService.h
new file mode 100644
--- /dev/null
+++ b/browser/components/shell/nsKDEShellService.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef nskdeshellservice_h____
+#define nskdeshellservice_h____
+
+#include "nsIGNOMEShellService.h"
+#include "nsToolkitShellService.h"
+#include "nsString.h"
+#include "mozilla/Attributes.h"
+
+class nsKDEShellService final : public nsIGNOMEShellService,
+                                public nsToolkitShellService
+{
+public:
+  nsKDEShellService() : mCheckedThisSession(false) { }
+
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISHELLSERVICE
+  NS_DECL_NSIGNOMESHELLSERVICE
+
+  nsresult Init();
+
+private:
+  ~nsKDEShellService() {}
+
+  bool mCheckedThisSession;
+};
+
+#endif // nskdeshellservice_h____
diff --git a/browser/components/shell/nsUnixShellService.cpp b/browser/components/shell/nsUnixShellService.cpp
new file mode 100644
--- /dev/null
+++ b/browser/components/shell/nsUnixShellService.cpp
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+#include "nsUnixShellService.h"
+#include "nsGNOMEShellService.h"
+#include "nsKDEShellService.h"
+#include "nsKDEUtils.h"
+#include "mozilla/ModuleUtils.h"
+
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGNOMEShellService, Init)
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsKDEShellService, Init)
+
+NS_IMETHODIMP
+nsUnixShellServiceConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
+{
+    if( nsKDEUtils::kdeSupport())
+        return nsKDEShellServiceConstructor( aOuter, aIID, aResult );
+    return nsGNOMEShellServiceConstructor( aOuter, aIID, aResult );
+}
diff --git a/browser/components/shell/nsUnixShellService.h b/browser/components/shell/nsUnixShellService.h
new file mode 100644
--- /dev/null
+++ b/browser/components/shell/nsUnixShellService.h
@@ -0,0 +1,15 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+
+#ifndef nsunixshellservice_h____
+#define nsunixshellservice_h____
+
+#include "nsIGNOMEShellService.h"
+
+NS_IMETHODIMP
+nsUnixShellServiceConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult);
+
+#endif // nsunixshellservice_h____

@francoism90
Copy link

@smsxgli Thanks for patch! I have turned your changes into a patch file, which should applied after applying all other ones:

--- a/browser/components/shell/nsKDEShellService.cpp
+++ b/browser/components/shell/nsKDEShellService.cpp
@@ -101,3 +101,11 @@
     return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+
+NS_IMETHODIMP
+nsKDEShellService::IsDefaultForScheme(nsTSubstring<char> const& aScheme, 
+                                             bool* aIsDefaultBrowser)
+{
+    return NS_ERROR_NOT_IMPLEMENTED;
+}
+

You can checkout the updated sources as well. :)

Thanks for all your help! Maybe you should open a PR?

@smsxgli
Copy link
Author

smsxgli commented Oct 24, 2021

@francoism90 I will have a test soon. By the way, I met a link error about LLVM again with your last PKGBUILD and the modified patch.
And I may not open a PR for this, because since only clang users will meet this issue, and KDE seems only support gcc build.
If you want to, please feel free to open a PR for this error.

wrosenauer pushed a commit that referenced this issue Nov 9, 2021
removed obsolete patches
  * mozilla-bmo1602730.patch
  * mozilla-bmo1725828.patch
  * mozilla-bmo1729124.patch
fix Plasma detection (boo#1191825)
fix Link error "undefined hidden symbol:"
  #37
@smsxgli
Copy link
Author

smsxgli commented Nov 16, 2021

This error should be solved in commit f41e1b2623e162339286610070c059afe5106c25. Thanks!

@smsxgli smsxgli closed this as completed Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants