Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98362 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20126 invoked from network); 28 Feb 2017 19:13:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Feb 2017 19:13:50 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.128.176 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.128.176 mail-wr0-f176.google.com Received: from [209.85.128.176] ([209.85.128.176:36166] helo=mail-wr0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 58/30-16445-CEBC5B85 for ; Tue, 28 Feb 2017 14:13:49 -0500 Received: by mail-wr0-f176.google.com with SMTP id u108so15425522wrb.3 for ; Tue, 28 Feb 2017 11:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:from:date:message-id:subject:to; bh=Jy84jD4D8vtLyQrMGG1nMB8cu9Kje4tRAl/ft06hUAU=; b=yfzaefTshOCG3jWSUx5R5s8O3l/EwEhFeFgNVmVW8ZK0nqJGJQAB3Gbh46Hy/jWtQz zCGc7xQr9xrx0FW3Z1JdwcDhxkLJELw7jHmcj/oXXlhR6RRslcZoeH9E/TuBf5jKXCuc VPiwhekN9/YahWVlAHZFu/M25DupTX1TaH38l4nOyP8Rp5pvEwsWCLqVJTdoMxoZ9KoL Ft1l9e39NOzsBpP4jvlZ8o24jhTjeZl6mPC/TQZ2/Pm0keBJ7/geXERHfAwGDbkui2dk ABqXfd3+zI86czGT2DURfFlblbjQa05EcGAh3Lxe/RQOVyTMM/e+2j3vryMXduwLVCMf eW+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=Jy84jD4D8vtLyQrMGG1nMB8cu9Kje4tRAl/ft06hUAU=; b=OxYgh2RmVYRasxFpCH0mgLto2eCvyD++CIiw2L7weG5ZmhRrxMhehXo2ijokp0O+xU CJPRbdqH4eQ1A8IzLUfY0gTUcNU9+wqrqOMtlS1TaOUMQU2utK+T8RVFWsBYwqExOn8a +7bguqpaPK76i11fXsfIqCyDz5baJO48AsObFGilxZoTxWykKFp+GXNGfHp+LHPt2vOv 2dpESQNIjNJM6A4hf1f+xaQJl3WGmM3ssCnIkb7mUWmEj9ecj1W2/wPk8MHxYV1Cf27H xulpiQgzE4Cgsi5PCWYk9Krg7AgSQ44w7Fu6ot80wAT9xOLzIIT6wnlwmHpSTbz9r5bN B/xw== X-Gm-Message-State: AMke39kI4VcVwn0e48HBdIzwEeHf5pqeXabpguvB+7L5unBnsp7fRy4cnDWpDjSqGy98ShqpWutjrZLYp4eL3w== X-Received: by 10.223.152.239 with SMTP id w102mr3511430wrb.72.1488309225200; Tue, 28 Feb 2017 11:13:45 -0800 (PST) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.152.233 with HTTP; Tue, 28 Feb 2017 11:13:44 -0800 (PST) X-Originating-IP: [73.9.224.155] Date: Tue, 28 Feb 2017 13:13:44 -0600 X-Google-Sender-Auth: dwhztPdmcULdRiY0IR1aXat48Oc Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: [Request for Comment] Loading dynamic libraries with cross dependencies. From: pollita@php.net (Sara Golemon) The average PHP extension is dependent only on the PHP runtime it was built for and probably one or more 3rd party libraries. However, a special class of extensions (such as PDO drivers and much of the XML family) have dependencies on other PHP extensions which may (or may not) be preset at the time they are loaded in via ini settings and/or dl(). This situation was partially addressed by Wez back in PHP 5.2 with the addition of zend_module_dep in the module entry header. Combined with RTLD_LAZY during DL_LOAD() (a portability macro for dlopen()), this allows modules to be inspected for dependencies and conflicts prior to being registered with the runtime. Unfortunately RTLD_LAZY has some limitations. From `man dlopen`: """Lazy binding is performed only for function references; references to variables are always immediately bound when the shared object is loaded.""" Given PHP's heavy use of XG() macros to access "globals", the odds of a missing symbol during module load is therefore fairly high resulting in an inability to inspect zend_module_dep structures and provide a meaningful error message to end users. Why do I care what the error message looks like? Full disclosure: The company I work for wants to know reliably what order to list extensions in php.ini files that are partially autogenerated. atm this comes in the form of an explicitly curated relationships table, but that's not the most scalable approach. Additionally, resolving this will likely help other users when presented with what are currently somewhat cryptic load errors. (e.g. "Unable to load 'foo': unresolved symbol _libf2_blarg") I'd like to open a discussion on how we might address this in future releases of PHP. Some back-of-the-napkin brainstorming has yielded the following, but I'd love to hear others' thoughts on the subject: Make use of the already extant PHP_ADD_EXTENSION_DEP config.m4 macro to produce a look-aside data structure which can be accessed without fully loading the extension. This look-aside could be stored in an arbitrary .text section in the DSO or as a separate file. (I prefer bundling with the DSO for what I hope are obvious reasons). -Sara