Closed Bug 1445937 Opened 6 years ago Closed 6 years ago

gfx/angle is missing code for Solaris (and BSD)

Categories

(Firefox :: Untriaged, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1442791

People

(Reporter: petr.sumbera, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0
Build ID: 20180310025718

Steps to reproduce:

$ ls -1 gfx/angle/checkout/src/common/system_utils_*
gfx/angle/checkout/src/common/system_utils_linux.cpp
gfx/angle/checkout/src/common/system_utils_mac.cpp
gfx/angle/checkout/src/common/system_utils_win.cpp

And in gfx/angle/targets/angle_common/moz.build:

if CONFIG['OS_ARCH'] == 'Darwin':
    SOURCES += [
        '../../checkout/src/common/system_utils_mac.cpp',
    ]
if CONFIG['OS_ARCH'] == 'Linux':
    SOURCES += [
        '../../checkout/src/common/system_utils_linux.cpp',
    ]
if CONFIG['OS_ARCH'] == 'WINNT':
    SOURCES += [
        '../../checkout/src/common/system_utils_win.cpp',
    ]
For Solaris I have following workaround. The issue is that these are not Firefox sources. Any comment welcome.

diff -r c56ef1c14a55 gfx/angle/targets/angle_common/moz.build
--- a/gfx/angle/targets/angle_common/moz.build  Wed Mar 14 00:40:07 2018 +0200
+++ b/gfx/angle/targets/angle_common/moz.build  Thu Mar 15 10:29:22 2018 +0000
@@ -122,7 +122,7 @@
     SOURCES += [
         '../../checkout/src/common/system_utils_mac.cpp',
     ]
-if CONFIG['OS_ARCH'] == 'Linux':
+if CONFIG['OS_ARCH'] == 'Linux' or CONFIG['OS_ARCH'] == 'SunOS':
     SOURCES += [
         '../../checkout/src/common/system_utils_linux.cpp',
     ]
diff -r c56ef1c14a55 gfx/angle/checkout/src/common/system_utils_linux.cpp
--- a/gfx/angle/checkout/src/common/system_utils_linux.cpp      Wed Mar 14 00:40:07 2018 +0200
+++ b/gfx/angle/checkout/src/common/system_utils_linux.cpp      Thu Mar 15 13:13:43 2018 +0000
@@ -8,6 +8,7 @@

 #include "system_utils.h"

+#include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
@@ -27,6 +28,14 @@
     // so we just use a big buffer and hope the path fits in it.
     char path[4096];

+#if __sun__
+    int fd;
+    snprintf(path, sizeof(path), "/proc/%d/path/a.out", getpid());
+    if ((fd = open(path, O_RDONLY)) == -1)
+      return "";
+    if (frealpath(fd, path, sizeof(path)) == NULL)
+      return "";
+#else
     ssize_t result = readlink("/proc/self/exe", path, sizeof(path) - 1);
     if (result < 0 || static_cast<size_t>(result) >= sizeof(path) - 1)
     {
@@ -34,6 +43,7 @@
     }

     path[result] = '\0';
+#endif
     return path;
 }
Probably a duplicate of bug 1442791.

(In reply to Petr Sumbera from comment #1)
> +#if __sun__
> +    int fd;
> +    snprintf(path, sizeof(path), "/proc/%d/path/a.out", getpid());
> +    if ((fd = open(path, O_RDONLY)) == -1)
> +      return "";

Does this imply readlink() or /proc may not be available on Solaris? Otherwise, why differ from the existing code.

https://searchfox.org/mozilla-central/rev/6e96a3f1e44e286ddae5fdafab737709741d237a/xpcom/build/BinaryPath.h#161
You are right. Following should be enough:

--- a/gfx/angle/checkout/src/common/system_utils_linux.cpp      Wed Mar 14 00:40:07 2018 +0200
+++ b/gfx/angle/checkout/src/common/system_utils_linux.cpp      Mon Mar 19 12:20:42 2018 +0000
@@ -27,7 +27,11 @@
     // so we just use a big buffer and hope the path fits in it.
     char path[4096];

+#if __sun__
+    ssize_t result = readlink("/proc/self/path/a.out", path, sizeof(path) - 1);
+#else
     ssize_t result = readlink("/proc/self/exe", path, sizeof(path) - 1);
+#endif
     if (result < 0 || static_cast<size_t>(result) >= sizeof(path) - 1)
     {
         return "";


And yes it's duplicate of bug 1442791.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.