[macports-ports] 03/06: cxx11 PG: do not force the use of depends_lib-append

Ryan Schmidt ryandesign at macports.org
Fri Dec 8 12:28:05 UTC 2017


On Dec 8, 2017, at 00:56, Joshua Root wrote:
> On 2017-12-8 16:54 , Marcus Calhoun-Lopez wrote:
>> On Thu, Dec 7, 2017 at 9:37 PM, Joshua Root wrote:
>>> On 2017-12-8 10:01 , Marcus Calhoun-Lopez wrote:
>>>> On Mon, Dec 4, 2017 at 10:23 PM, Ryan Schmidt wrote:
>>>>> 
>>>>> Also, why `global os.major`? It's not used...
>>>> os.major is used in line 52 [1].
>>> 
>>> But not inside the register_gcc_dependents (now cxx11.add_dependencies)
>>> proc.
>> 
>> As far as I can tell, cxx11.add_dependencies (formally
>> register_gcc_dependents) begins on line 47 [1] and ends on line 58
>> [2].
>> os.major is used in line 52 [3].
>> Doesn't that put it within the procedure?
>> And doesn't that in turn necessitate the statement `global os.major`
>> on line 48 [4]?
>> 
>> Please forgive me if I am missing something obvious.
> 
> I see, it is used now. It wasn't in the commit that Ryan was commenting
> on. Sorry for the confusion. :)

But now the proc is doing more than just adding dependencies. It's doing:


    proc cxx11.add_dependencies {} {
        global os.major os.platform
        depends_lib-delete port:libgcc
        depends_lib-append port:libgcc
        # ensure desired compiler flags are present
        if {${os.platform} eq "darwin" && ${os.major} < 13} {
            configure.cxxflags-delete    -D_GLIBCXX_USE_CXX11_ABI=0
            configure.cxxflags-append    -D_GLIBCXX_USE_CXX11_ABI=0
            configure.objcxxflags-delete -D_GLIBCXX_USE_CXX11_ABI=0
            configure.objcxxflags-append -D_GLIBCXX_USE_CXX11_ABI=0
        }
    }
    # do not force all Portfiles to switch from depends_lib to depends_lib-append
    port::register_callback cxx11.add_dependencies


I understand that the whole reason why you're putting this code in a procedure is so that it runs after the rest of the portfile's code runs, so that the portfile is free to declare dependencies without risk of clobbering dependencies added by the portgroup.* But that can also be a problem, because the portfile's code can't access anything done by this procedure. For dependencies that's probably ok, but for cxxflags it could very well not be ok. Many ports don't have configure phases, so they need to convey configure.cxxflags and other variables to the build system in another way, for example by adding them to build.args.

See some discussion about the same problem in another portgroup trying to adopt this method:

https://trac.macports.org/ticket/55469

I suggest the proc should *only* add dependencies, nothing else.



*We could just continue to require, as we have up to now, that portfiles that include portgroups should always use e.g. depends_lib-append and not depends_lib. However, I recognize that time and again we see problems because portfile authors don't follow that requirement, and if we can find a way to avoid that requirement, that would be great.




More information about the macports-dev mailing list