Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006167OCamlOCaml backend (code generation)public2013-09-10 16:202014-08-21 12:02
Assigned To 
PlatformOSOS Version
Product Version4.01.0+beta/+rc 
Target VersionFixed in Version 
Summary0006167: OCAMLPARAM Support for Disabling Position-Independent Code (PIC) Generation
DescriptionAdd support for disabling Position-Independent Code (PIC) generation through the OCAMLPARAM environment variable. This change would make it possible to specify a "nopic" token which, when set, instructs the native code generator to emit position-dependent code independently of what was requested at the command line.

The rationale of this option is similar to the other flags already supported by OCAMLPARAM: Allow the user to force generation of position-dependent code without the need for modifying build system files or sources.

This patch was directly motivated by the need for making cross-compilation possible of the Mirage unikernel [1] to the "kFreeBSD" backend. This backend basically compiles Mirage (OCaml) programs into FreeBSD kernel modules, where certain expectations must be satisfied. One of those expectations is that the generated code must not be position-independent as the FreeBSD kernel dynamic loader (kld(4)) does not support ELF relocations of that type. Hence PIC generation has to be disabled globally for all the compiled code, regardless what the original upstream packages were instructed for. The "nodynlink" flag is also used in this case.

The attached patch implements this functionality by moving the `pic_code` variable to the `Clflags` module for both the AMD64 and the ARM native code generator backends, while it retains the default settings for both. I have tested it on FreeBSD/amd64, but it should work on the ARM platform and on other operating systems.

[1] [^]
Attached Filesdiff file icon nopic.diff [^] (8,737 bytes) 2013-09-10 16:20 [Show Content]

- Relationships

-  Notes
doligez (administrator)
2014-04-02 17:11

One small remark: if we add a "nopic" flag we should also add a "pic" flag for symmetry (and because all the hard work is already done).

- Issue History
Date Modified Username Field Change
2013-09-10 16:20 pgj New Issue
2013-09-10 16:20 pgj File Added: nopic.diff
2013-09-11 22:07 doligez Tag Attached: patch
2014-04-02 17:09 doligez Status new => confirmed
2014-04-02 17:09 doligez Target Version => 4.02.0+dev
2014-04-02 17:11 doligez Note Added: 0011174
2014-08-21 12:02 doligez Target Version 4.02.0+dev =>

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker