Opened 4 years ago

Closed 4 years ago

#52442 closed defect (fixed)

opencsg @1.4.0 does not honor -stdlib=libc++ and patch to fix

Reported by: ken-cunningham-webuse Owned by: dstrubbe (David Strubbe)
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: Cc: dstrubbe (David Strubbe)
Port: opencsg

Description

openCSG is a component of OpenSCAD. By default, it does not honour -stdlib=libc++, and links against libstdc++.

$ otool -L libopencsg.1.4.0.dylib
libopencsg.1.4.0.dylib:
	/opt/local/lib/libopencsg.1.dylib (compatibility version 1.4.0, current version 1.4.0)
	/opt/local/lib/libGLEW.2.0.0.dylib (compatibility version 2.0.0, current version 2.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)

there is no configure script to send arguments to, so the attached patch modifies the Portfile to reinplace the Makefile directly to make it link to the correct libc++.

See also [ticket:51840}

After patch:

$ otool -L libopencsg.1.4.0.dylib
libopencsg.1.4.0.dylib:
	/opt/local/lib/libopencsg.1.dylib (compatibility version 1.4.0, current version 1.4.0)
	/opt/local/lib/libGLEW.2.0.0.dylib (compatibility version 2.0.0, current version 2.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 3.7.1)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
	/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 3.7.0)

Attachments (1)

opencsg-libcxx-fix.diff (1012 bytes) - added by ken-cunningham-webuse 4 years ago.

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by ken-cunningham-webuse

Attachment: opencsg-libcxx-fix.diff added

comment:1 Changed 4 years ago by dstrubbe (David Strubbe)

Owner: changed from macports-tickets@… to dstrubbe@…

comment:2 Changed 4 years ago by dstrubbe (David Strubbe)

Do we really need to add "-std=c++11" for these purposes? For the record, yes the configure options are used by the qmake portgroup.

comment:3 in reply to:  2 Changed 4 years ago by larryv (Lawrence Velázquez)

That seems like an overreach to me. Don’t force C++11 if the source code doesn’t require it.

Also: The test is too weak. You should also be testing that the platform is Darwin and the compiler is Clang.

comment:4 Changed 4 years ago by ken-cunningham-webuse

Wasn't 100% sure of the c++11 part for opencsg, but openscad uses c++11 so I I added it here too. It works, but maybe isn't needed. I didn't deeply dig into that part of it.

After configuring, I couldn't find the optflag in the Makefile....

configure.optflags  -O3
Last edited 4 years ago by ken-cunningham-webuse (previous) (diff)

comment:5 Changed 4 years ago by dstrubbe (David Strubbe)

Do me a favor, try this more general patch and see if it puts the right thing into CXXFLAGS in your Makefiles.

Index: ../../_resources/port1.0/group/qmake-1.0.tcl
===================================================================
--- ../../_resources/port1.0/group/qmake-1.0.tcl        (revision 153298)
+++ ../../_resources/port1.0/group/qmake-1.0.tcl        (working copy)
@@ -44,8 +44,9 @@
     configure.pre_args-append       PREFIX=${prefix} \
                                     "QMAKE_CC=${configure.cc}" \
                                     "QMAKE_CXX=${configure.cxx}" \
-                                    "QMAKE_OBJC=${configure.objc}"
-    configure.args-append           "CFLAGS=\"${configure.cflags} [get_canonical_archflags cc]\""
+                                    "QMAKE_OBJC=${configure.objc}" \
+                                    "QMAKE_CFLAGS=\"${configure.cflags} [get_canonical_archflags cc]\"" \
+                                    "QMAKE_CXXFLAGS=\"${configure.cxxflags} [get_canonical_archflags cxx]\""
     configure.universal_args-delete --disable-dependency-tracking
 
     if {[variant_exists universal] && [variant_isset universal]} {

comment:6 Changed 4 years ago by ken-cunningham-webuse

That works beautifully on this 10.6 / LibCxx machine. That looks like the elegant solution I suspected must exist, but didn't know where to put or how to do. Thanks!

OpenCSG and openSCAD build through to completion now without touching a thing. I thought the hard-coded 10.7 deployment target in the openscad makefile might mess things up, but it did not seem to affect anything.

Complete success.

comment:7 Changed 4 years ago by dstrubbe (David Strubbe)

Resolution: fixed
Status: newclosed

qmake portgroup change committed in r153331.

Note: See TracTickets for help on using tickets.