World: r3wp
[!REBOL3 Extensions] REBOL 3 Extensions discussions
older newer | first last |
Andreas 26-Jan-2011 [2315] | But in any case, as you say, _don't_ take away the ability to just have extension search managed by OS mechanisms. |
Kaj 26-Jan-2011 [2316] | Exactly, and in a portable way |
BrianH 26-Jan-2011 [2317x2] | If you want to fully integrate R3 into an OS, that is a job for the host code. For most OSes you want as much isolation between the OS and R3 as you can get. Unless you have a locked-down OS (most don't) then what constitutes a "safe" extension would vary widely between programs. That is why the module-paths option and others like it are just set by default by the startup code, to be changeable by the program code as needed. |
We do have a way to have extension search managed in a portable way by OS-specific means: LOAD-EXTENSION is implemented in the host code. | |
Andreas 26-Jan-2011 [2319x2] | Yes, and all we need to do is add some simple filename management to it. |
Which doesn't make any sense at all to replicate for each and every otherwise portable extension. | |
Kaj 26-Jan-2011 [2321] | Sigh. I'm not going to spend another day rehashing that it's currently not portable, because of the very simple detail Andreas says |
BrianH 26-Jan-2011 [2322] | Yup. But keep in mind that for most potential R3 users (who like most users are running Windows, OSX or some stock Linux) the OS mechanisms for managing libraries shared between programs are really poor, and they are encouraging program-specific storage. I'm really interested in how you will experiment with integrating R3 with a properly managed OS, which (I hope) Syllable is. |
Andreas 26-Jan-2011 [2323] | loader mechanisms on linux are anything but poor (at least compared to windows) |
BrianH 26-Jan-2011 [2324] | Damned by faint praise, but true. The real trick is to make sure that LOAD-EXTENSION doesn't try to load non-extension system libraries. |
Andreas 26-Jan-2011 [2325x2] | why? it will fail anyway |
no need to needlessly overcomplicate things | |
Kaj 26-Jan-2011 [2327] | Even though Syllable has its own dynamic loader in the kernel, we're not managing user space libraries vastly differently than Linux, which has a user space loader. The difference is in kernel drivers, which are standard ELF libraries just like user space libraries, which isn't possible in Linux. I consider this similar to the nice circumstance that R3 extensions are native OS libraries, which has similar integration benefits - if you take advantage of them |
BrianH 26-Jan-2011 [2328] | The idea of a "safe" extension is tenuous at best as it is. Don't add the possibility of having some system-specific libraries polluting the file name space. For instance, I would consider one of the minimum requirements of a system-installed "safe" extension to be that it be guaranteed delayable. |
Andreas 26-Jan-2011 [2329x2] | Nobody but you is talking about "safe" extensions. |
We are talking about making those pesky & horrendously unsafe native extensions work slightly more smoothly across platforms. | |
Kaj 26-Jan-2011 [2331] | If you want safe binary extensions, rewrite REBOL on Genode with a GPL license. Anything less won't do |
BrianH 26-Jan-2011 [2332] | One interesting thing you haven't considered: sys/load-module calls lib/load-extension without checking whether it is native. You can override lib/load-extension with a REBOL code wrapper, in %rebol.r even. Then you can do any safe lookups you like without messing with host code, and even translate .rx suffixes to .so if you like. |
Andreas 26-Jan-2011 [2333] | Interesting indeed. But one of the main points is that condemning this functionality into %rebol.r is not sufficient. |
BrianH 26-Jan-2011 [2334] | This is a great way to experiment with platform integration, and what you learn can be adapted to the host code. |
Andreas 26-Jan-2011 [2335] | Also, I don't think that triggering platform-specific suffix replacement by using %filename.rx is a particularly good idea (too much magic). But it is one option. |
BrianH 26-Jan-2011 [2336] | I don't think using a platform-specific suffix for a cross-platform extension and then expecting code that uses it to be cross-platform is a good idea. YMMV. |
Andreas 26-Jan-2011 [2337x3] | Yeah, as should be obivious Kaj and me strongly disagree with this sentiment. |
The extension file itself is not cross-platform (in most cases, at least), therefore using a standard suffix is extremely appropriate. | |
And "code that uses it" can trivially be cross-platform. We only need to solve the filename issue. | |
BrianH 26-Jan-2011 [2340x2] | Yup. But that's why extension lookup is implemented in a platform-specific way, internally, to gloss over those differences. |
Fortunately there aren't many platforms that only use platform-specific filenames for dynamic libraries. Those can be adjusted for. At least the .rx naming convention is better than something like -rxt.so or something. | |
Andreas 26-Jan-2011 [2342] | Brian, it really is not about "platforms that only use platform-specific filenames". |
BrianH 26-Jan-2011 [2343] | Really? Because't on Windows and OSX this is not an issue, this is expected behavior. |
Andreas 26-Jan-2011 [2344] | Linux's loader in general couldn't care less about the extension of a shared object. That doesn't make it any less prudent to stick with the standard .so extension. |
BrianH 26-Jan-2011 [2345x2] | prudent to stick with the standard .so extension - I'm having a little trouble understanding this, but maybe that comes from too much experience with platforms where it has been demonstrated that there are advantages to distinguishing between different dynamic library types by using different file suffixes. The "standard .so extension" means that these differences get put somewhere else in the filename. But I can see your point with libraries like System.Data.Sqlite that support more than one calling convention in the same file, so that the R3 extension API would just be added to a system dynamic library that is otherwise meant to be called by non-REBOL code - incorporating its own wrapper extension. |
Remember, on many Linuxes you just want to load libc, but the actual file is something like libc.so.6 or something (I'm paraphrasing here). Having LOAD-EXTENSION translate .rx is no different from that. You can even have a filename map on your platform if you like. | |
Kaj 26-Jan-2011 [2347x2] | It is different, as in the Linux case you add the standard extension, while in the REBOL case you want to change the extension. The latter is less expected, so more confusing |
There is no further translation happening on Linux from libc.so to libc.so.6 as that is just a symlink in the file system | |
Andreas 28-Jan-2011 [2349x8] | Based on our discussions I started writing an improved extension loading mechanism: https://github.com/earl/rebol3/blob/master/modules/extload.r3 |
It's main purpose is to translate a "generic" extension suffix (%.rx per default) to platform-specific extension suffixes (yes, potentially many). | |
It hooks into the extension loading process (LOAD-EXTENSION) as suggested by Brian, so it works transparently. | |
All you have to do to use it, is to import the 'extload module first, before you import any native extension. After that, use the generic suffix to load extensions. For example, let's assume you want to load your platform's cURL-binding.* extension: import %extload.r3 import %cURL-binding.rx On Linux (in the system/platform/1 sense) and FreeBSD, this will first attempt to load %cURL-binding.rx and if that fails, %cURL-binding.so. On Windows, %cURL-binding.rx and %cURL-binding.dll are tried (in this order). On OSX, %cURL-binding.rx, %cURL-binding.dylib and %cURL-binding.so are tried (in this order). | |
The actual suffixes tried are by default taken from system/options/file-types. | |
Filenames not ending in the generic suffix are left as-is; so event with extload present, if can use e.g. import %cURL-binding.so directly and bypass the suffix translation mechanism. | |
I hope extload to be a suitable foundation upon which to further discuss these matters. | |
And for this to lead to eventually integrating an improved loading mechnism directly into R3. | |
BrianH 28-Jan-2011 [2357x5] | You can try them in the order the suffixes appear in system/options/file-types. That way your code doesn't have to special-case per platform; let the host code special-case it instead. Just in case .rx isn't supported on a platform, you might consider searching for 'extension and backtracking to get the file! suffixes. |
The .rx suffix seems to come first in the platforms I know of. | |
>> find/reverse/tail find system/options/file-types 'extension word! == [%.rx %.dll extension] | |
If you are doing this already, consider it documentation for the others :) | |
Do we need a system/options/extension-paths setting? You could add it to system/options in your %extload.r3, and it would let you preconfigure your system with a directory of shared extensions, if such a thing exists. Or it could just be assigned the same block as system/options/module-paths by default. | |
Andreas 28-Jan-2011 [2362x2] | Yes, Brian, as I stated above I'm already using system/options/file-types. Quoting myself: The actual suffixes tried are by default taken from system/options/file-types. |
An extension-paths setting and searching this path would be a good option (esp. on platforms with weaker loaders). But more about this later, gotta run :) | |
Robert 13-Feb-2011 [2364] | I'm fighting with some "undefined references" (.text+0x867): undefined reference to `RXARG_SERIES' |
older newer | first last |