Opened 6 years ago

Closed 6 years ago

#56603 closed defect (fixed)

zstd: error: expected ')'

Reported by: kencu (Ken) Owned by: seanfarley (Sean Farley)
Priority: Normal Milestone:
Component: ports Version:
Keywords: haspatch Cc: ryandesign (Ryan Carsten Schmidt)
Port: zstd

Description

zstd build fails on darwin 12 and older. There are two issues:

Firstly, on 10.6 and older, it requires __STDC_FORMAT_MACROS to be defined due to changes in inttypes.h on 10.7 and newer, and generates this error otherwise:

Pzstd.cpp:104:46: error: expected ')'
      state.log(INFO, "%-20s :%6.2f%%   (%6" PRIu64 " => %6" PRIu64

and secondly, the port uses c++11:

/opt/local/bin/clang++-mp-3.9 -arch x86_64 -MMD -MP -MF main.Td   -I../../lib -I../../lib/common -I../../programs -I. -DNDEBUG -O3 -Wall -Wextra -pedantic  -std=c++11 -c main.cpp  -o main.o
mv -f main.Td main.d

and so needs the c++11 PortGroup.

Attachments (1)

main.log (49.7 KB) - added by kencu (Ken) 6 years ago.
build with clang-3.9 on 10.6.8

Download all attachments as: .zip

Change History (10)

comment:1 Changed 6 years ago by kencu (Ken)

Owner: set to LogicalKnight
Status: newassigned

Logfile attached

Last edited 6 years ago by kencu (Ken) (previous) (diff)

Changed 6 years ago by kencu (Ken)

Attachment: main.log added

build with clang-3.9 on 10.6.8

comment:2 Changed 6 years ago by kencu (Ken)

These two issues can be fixed with this patch:

$ diff -u /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/archivers/zstd/Portfile /opt/SnowLeopardPorts/archivers/zstd/Portfile
--- /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/archivers/zstd/Portfile	2018-05-31 12:09:04.000000000 -0700
+++ /opt/SnowLeopardPorts/archivers/zstd/Portfile	2018-06-03 20:50:22.000000000 -0700
@@ -2,6 +2,7 @@
 
 PortSystem          1.0
 PortGroup           github 1.0
+PortGroup           cxx11 1.1
 
 github.setup        facebook zstd 1.3.4 v
 categories          archivers devel
@@ -27,14 +28,22 @@
 
 variant universal {}
 
-build.env-append    CC="${configure.cc} [get_canonical_archflags cc]" \
-                    CXX="${configure.cxx} [get_canonical_archflags cxx]" \
+# many inttypes are undefined on < 10.7 unless __STDC_FORMAT_MACROS is set
+if {${os.platform} eq "darwin" && ${os.major} < 11} {
+	set extraflags -D__STDC_FORMAT_MACROS
+} else {
+	set extraflags ""
+}
+
+
+build.env-append    CC="${configure.cc} [get_canonical_archflags cc] ${extraflags}" \
+                    CXX="${configure.cxx} [get_canonical_archflags cxx] ${extraflags}" \
                     CFLAGS="${configure.cflags}" \
                     PREFIX="${prefix}"
 
 use_parallel_build  no
 
-destroot.env-append CC="${configure.cc} [get_canonical_archflags cc]" \
-                    CXX="${configure.cxx} [get_canonical_archflags cxx]" \
+destroot.env-append CC="${configure.cc} [get_canonical_archflags cc] ${extraflags}" \
+                    CXX="${configure.cxx} [get_canonical_archflags cxx] ${extraflags}" \
                     CFLAGS="${configure.cflags}" \
                     PREFIX="${prefix}"

comment:3 Changed 6 years ago by kencu (Ken)

I notice the -stdlib=libXYZ is not set either, so that will need to be added as well, it appears.

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

Owner: changed from LogicalKnight to seanfarley
Port: zstd added

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

The -stdlib=... flag is in configure.cxxflags. The port just needs to use it.

Instead of making a new variable extraflags, it seems like it would be easier to just append the needed flag(s) to configure.cflags and/or configure.cxxflags (when needed) since those are (or will be) used already.

comment:6 Changed 6 years ago by kencu (Ken)

I see you do that Makefile magic. I will give it a look -- I certainly don't see Makefiles quite as clearly as you do, and doubt I ever will!

comment:7 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign added
Keywords: haspatch added

It looks like C++11 is only used to build pzstd. pzstd is part of contrib, which is built by default, but is not installed by default. So one solution, rather than using the cxx11 1.1 portgroup, would be to no longer build contrib. This also seems to make unnecessary the setting of -D__STDC_FORMAT_MACROS; it builds fine for me on 10.6 without that now. For that matter, we don't need to build the manual or examples either, since they're not installed either.

https://github.com/macports/macports-ports/pull/1997

comment:8 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

In d6397b01b23a9bddbbc257fb3ce0fec11a7bf546/macports-ports (master):

zstd: Use MacPorts CXXFLAGS and LDFLAGS

This ensures the right C++ standard library and optimization flags are
used when building, and maximum header padding is used while linking.

See: #56603

comment:9 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: assignedclosed

In 2e5cf4a3feabd8ca7ff4947f4c69e312103babc9/macports-ports (master):

zstd: Don't build examples, manual, or contrib

They're not installed, one of the contrib programs requires C++11, and
the Makefile doesn't correctly handle building them in parallel.

Closes: #56603

Note: See TracTickets for help on using tickets.