Opened 2 years ago

Closed 6 weeks ago

#52477 closed defect (fixed)

rtorrent: Update to 0.9.6 w/ patches for macOS 10.12

Reported by: torstenb@… Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: sierra haspatch Cc: tsjk (Tamas Jantvik)
Port: rtorrent

Description (last modified by ryandesign (Ryan Schmidt))

Updating rtorrent to 0.9.6 and adding patches to build with newer clang on macOS Sierra 10.12. New patches are from current FreeBSD ports tree. Depends on newer libtorrent in trac ticket:52476

Attachments (4)

patch-extra-clang.diff (23.5 KB) - added by torstenb@… 2 years ago.
patch-src_display_window_file_list.diff (242 bytes) - added by torstenb@… 2 years ago.
patch-src_signal_handler.diff (225 bytes) - added by torstenb@… 2 years ago.
Portfile.diff (2.1 KB) - added by torstenb@… 2 years ago.

Download all attachments as: .zip

Change History (18)

comment:1 Changed 2 years ago by torstenb@…

Can't upload diff to Portfile as it matches BadContent entry "rak" + "sha". The developers username, also in the Websites URL, contains that string. Will add Portfile once BadContent entries allow it

Changed 2 years ago by torstenb@…

Attachment: patch-extra-clang.diff added

Changed 2 years ago by torstenb@…

Changed 2 years ago by torstenb@…

comment:2 Changed 2 years ago by mf2k (Frank Schima)

Keywords: sierra, haspatchsierra haspatch

It should work now.

Changed 2 years ago by torstenb@…

Attachment: Portfile.diff added

comment:3 in reply to:  2 Changed 2 years ago by torstenb@…

Replying to mf2k@…:

It should work now.

It does indeed. Thanks!

comment:4 Changed 2 years ago by ryandesign (Ryan Schmidt)

Your patch adds this block:

post-patch {
    system "find ${worksrcpath} \\( -name '*.h' -or -name '*.cc' \\) -type f -print0 | xargs -0 sed -i '' -e 's/tr1::/std::/g'" 
    system "find ${worksrcpath} \\( -name '*.h' -or -name '*.cc' \\) -type f -print0 | xargs -0 sed -i '' -e 's/std::std::/std::/g'" 
    system "find ${worksrcpath} \\( -name '*.h' -or -name '*.cc' \\) -type f -print0 | xargs -0 sed -i '' -e '/namespace tr1/d'" 
    system "find ${worksrcpath} \\( -name '*.h' -or -name '*.cc' \\) -type f -print0 | xargs -0 sed -i '' -e '/include/s,tr1/,,'" 
}

Ideally, you would use fs-traverse and reinplace, instead of system calling find, xargs and sed. Maybe something like this (untested):

post-patch {
    fs-traverse f ${worksrcpath} {
        switch [file extension ${f}] {
            .cc -
            .h {
                reinplace {s/std::std::/std::/g} ${f}
                reinplace {/namespace tr1/d} ${f}
                reinplace {/namespace tr1/d} ${f}
                reinplace {/include/s,tr1/,,} ${f}
            }
        }
    }
}

It looks like this will make the port work with compilers that support the final C++11 standard, but fail with compilers that only support the transitional tr1 standard. I wonder if you should only be doing this replacing when configure.cxx_stdlib is libc++. Or alternatively, maybe this code requires libc++; if so, include the cxx11 1.0 portgroup to handle the details. We can wait on this, commit it without such changes, and see whether it fails to build on the older Buildbot workers.

The same comments apply to libtorrent in #52476.

comment:5 Changed 2 years ago by ryandesign (Ryan Schmidt)

Description: modified (diff)

comment:6 Changed 2 years ago by jmroot (Joshua Root)

Owner: changed from macports-tickets@… to stuartwesterman
Status: newassigned

comment:7 Changed 2 years ago by stuartwesterman (Stuart Westerman)

Looks good!

comment:8 Changed 20 months ago by mf2k (Frank Schima)

Owner: stuartwesterman deleted
Last edited 20 months ago by mf2k (Frank Schima) (previous) (diff)

comment:9 Changed 9 months ago by tsjk (Tamas Jantvik)

What's the state of the art here? Would be a bit cool to have a working rtorrent in macports.

I managed to use the version in the tree, v0.9.2, by changing the version to v0.9.6, changing the homepage to http://rtorrent.net/, and forcing the compiler to be macports-gcc-6.

--- /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/net/rtorrent/Portfile     2017-11-17 14:52:13.000000000 +0100
+++ /usr/local/macports/ports/net/rtorrent/Portfile     2018-03-21 13:19:39.000000000 +0100
@@ -6,8 +6,8 @@
 name                rtorrent
 conflicts           rtorrent-devel
 set real_name       rtorrent
-version             0.9.2
-revision            2
+version             0.9.6
+revision            1
 categories          net
 platforms           darwin
 maintainers         nomaintainer
@@ -20,12 +20,12 @@
                     run in the background using screen. It supports fast-resume \
                     and session management.

-homepage            http://libtorrent.rakshasa.no/
+homepage            http://rtorrent.net/
 master_sites        ${homepage}downloads/
 distname            ${real_name}-${version}

-checksums           rmd160  130a4c7f3bd018f7247d4561170d6878ab7a120f \
-                    sha256  5c8f8c780bee376afce3c1cde2f5ecb928f40bac23b2b8171deed5cf3c888c3d
+checksums           rmd160  8ac9730ccd5544ee0f64628538a892d4f1d86081 \
+                    sha256  1e69c24f1f26f8f07d58d673480dc392bfc4317818c1115265b08a7813ff5b0e

 depends_build       port:pkgconfig

@@ -42,6 +42,9 @@
                     --disable-debug \
                     --enable-ipv6

+compiler.blacklist  *clang*
+configure.compiler   macports-gcc-6
+
 variant xmlrpc description {Enable XMLRPC interface} {
     configure.args-append   --with-xmlrpc-c
     depends_lib-append      port:xmlrpc-c

I used the same strategy for libtorrent, where I took the v0.13.2 version in tree, changed the verion to 0.13.6, changed the homepage to http://rtorrent.net/, and forced the compiler to macports-gcc-6.

--- /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/net/libtorrent/Portfile   2017-08-22 23:13:23.000000000 +0200
+++ /usr/local/macports/ports/net/libtorrent/Portfile   2018-03-21 13:19:09.000000000 +0100
@@ -4,7 +4,7 @@

 name                libtorrent
 conflicts           libtorrent-devel
-version             0.13.2
+version             0.13.6
 revision            1
 categories          net
 platforms           darwin
@@ -17,11 +17,11 @@
                     *nix. It is designed to avoid redundant copying and \
                     storing of data that other clients and libraries suffer from.

-homepage            http://libtorrent.rakshasa.no/
+homepage            http://rtorrent.net/
 master_sites        ${homepage}downloads/

-checksums           rmd160  090e6af9b4318a6176064159f6a8f70ab708c7fe \
-                    sha256  ed2f2dea16c29cac63fa2724f6658786d955f975861fa6811bcf1597ff8a5e4f
+checksums           rmd160  a143a0ef9e86cf989c2c7dff6c86a41d23ddc244 \
+                    sha256  2838a08c96edfd936aff8fbf99ecbb930c2bfca3337dd1482eb5fccdb80d5a04

 depends_build       port:pkgconfig

@@ -32,7 +32,8 @@
                     --enable-ipv6 \
                     --with-kqueue

-compiler.blacklist  gcc-4.0
+compiler.blacklist  *clang*
+configure.compiler   macports-gcc-6

 post-destroot {
     set docdir ${prefix}/share/doc/${name}

It compiles and runs, although I haven't started to use it as I'm checking whether I can swiftly switch from transmission to it and keeping my states. But I'd prefer a version that compiles with clang, of course.

comment:10 Changed 9 months ago by raimue (Rainer Müller)

The reason this does not work with clang, but works with macports-gcc-* is that the latter by default uses -stdlib=libstdc++, while clang defaults to -stdlib=libc++. This code is so old that it still uses includes headers from tr1/, a proposed standard from around 2005 that predates C++11 and was never part of libc++.

The problem is that code compiled with one C++ standard library is not necessarily compatible with code compiled with another. Therefore you have to be careful when mixing compilers. Even if it compiles, it may crash at runtime.

It appears that upstream actually fixed this in their git repository and got rid of the tr1/ includes, but the latest release 0.13.6 is from 2015 and does not contain these changes.

As upstream does not seem to bother to make releases, we should ditch the rtorrent and libtorrent ports and replace it with rtorrent-devel and libtorrent-devel ports that follow the current development on GitHub.

comment:11 Changed 9 months ago by tsjk (Tamas Jantvik)

Yeah, that sounds like a good idea. I haven't tried compiling the master branch at github with clang. Perhaps it'd just work, then. Another option then would perhaps be to append an stdlib flag to clang? Might try both options.

And I do of concur agree with it being a good idea not to mix compilers unless it's a last resort.

Last edited 9 months ago by tsjk (Tamas Jantvik) (previous) (diff)

comment:12 Changed 9 months ago by tsjk (Tamas Jantvik)

Indeed. The following seems to also be a working solution (at least it compiles, seemingly with clang):

--- /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/net/libtorrent/Portfile   2017-08-22 23:13:23.000000000 +0200
+++ /usr/local/macports/ports/net/libtorrent/Portfile   2018-03-22 14:00:36.000000000 +0100
@@ -4,8 +4,7 @@

 name                libtorrent
 conflicts           libtorrent-devel
-version             0.13.2
-revision            1
+version             0.13.6
 categories          net
 platforms           darwin
 maintainers         nomaintainer
@@ -17,11 +16,11 @@
                     *nix. It is designed to avoid redundant copying and \
                     storing of data that other clients and libraries suffer from.

-homepage            http://libtorrent.rakshasa.no/
+homepage            http://rtorrent.net/
 master_sites        ${homepage}downloads/

-checksums           rmd160  090e6af9b4318a6176064159f6a8f70ab708c7fe \
-                    sha256  ed2f2dea16c29cac63fa2724f6658786d955f975861fa6811bcf1597ff8a5e4f
+checksums           rmd160  a143a0ef9e86cf989c2c7dff6c86a41d23ddc244 \
+                    sha256  2838a08c96edfd936aff8fbf99ecbb930c2bfca3337dd1482eb5fccdb80d5a04

 depends_build       port:pkgconfig

@@ -34,6 +33,20 @@

 compiler.blacklist  gcc-4.0

+if {[string match "*clang*" ${configure.compiler}]} {
+    # Build fails using libc++
+
+    build.args-delete \
+        CXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libc++"
+    build.args-append \
+        CXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libstdc++"
+
+    build.args-delete \
+        OBJCXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libc++"
+    build.args-append \
+        OBJCXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libstdc++"
+}
+
 post-destroot {
     set docdir ${prefix}/share/doc/${name}
     xinstall -d ${destroot}${docdir}

--- /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/net/rtorrent/Portfile     2017-11-17 14:52:13.000000000 +0100
+++ /usr/local/macports/ports/net/rtorrent/Portfile     2018-03-22 14:00:40.000000000 +0100
@@ -6,8 +6,7 @@
 name                rtorrent
 conflicts           rtorrent-devel
 set real_name       rtorrent
-version             0.9.2
-revision            2
+version             0.9.6
 categories          net
 platforms           darwin
 maintainers         nomaintainer
@@ -20,12 +19,12 @@
                     run in the background using screen. It supports fast-resume \
                     and session management.

-homepage            http://libtorrent.rakshasa.no/
+homepage            http://rtorrent.net/
 master_sites        ${homepage}downloads/
 distname            ${real_name}-${version}

-checksums           rmd160  130a4c7f3bd018f7247d4561170d6878ab7a120f \
-                    sha256  5c8f8c780bee376afce3c1cde2f5ecb928f40bac23b2b8171deed5cf3c888c3d
+checksums           rmd160  8ac9730ccd5544ee0f64628538a892d4f1d86081 \
+                    sha256  1e69c24f1f26f8f07d58d673480dc392bfc4317818c1115265b08a7813ff5b0e

 depends_build       port:pkgconfig

@@ -42,11 +41,27 @@
                     --disable-debug \
                     --enable-ipv6

+compiler.blacklist  gcc-4.0
+
 variant xmlrpc description {Enable XMLRPC interface} {
     configure.args-append   --with-xmlrpc-c
     depends_lib-append      port:xmlrpc-c
 }

+if {[string match "*clang*" ${configure.compiler}]} {
+    # Build fails using libc++
+
+    build.args-delete \
+        CXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libc++"
+    build.args-append \
+        CXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libstdc++"
+
+    build.args-delete \
+        OBJCXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libc++"
+    build.args-append \
+        OBJCXXFLAGS="${configure.cxxflags} -pipe -Os -stdlib=libstdc++"
+}
+
 livecheck.type      regex
 livecheck.name      ${real_name}
 livecheck.url       ${master_sites}

I'm on El Capitain by the way, mostly due to laziness now, but previously because I use OpenZFS and macports, which often prohibits instant upgrades. :)

Last edited 9 months ago by tsjk (Tamas Jantvik) (previous) (diff)

comment:13 Changed 9 months ago by tsjk (Tamas Jantvik)

Cc: tsjk added

comment:14 Changed 6 weeks ago by kencu (Ken)

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.