-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to control PIC #365
Conversation
Can be used to override a platform-determined default. See MLton#191
Can be used to override a target-determined default. See MLton#191
Build all variants of the runtime along two axes: - mode - opt (no suffix) - debug (-dbg) - position independent - default (no suffix) - non-pi (-npi) - pic (-pic) - pie (-pie) One of `%-npi.a`, `%-pic.a`, and `%-pie.a` will be copied from `%.a`, depending on the default behavior of the C compiler.
559da66
to
82967ed
Compare
Can be used to override a target-determined default. Also, remove `-pic-runtime {false|true}` option. See MLton#191
Add options to control position-independent codeAdd Building on the changes in #361, a total of 12
The explicit The Compiling with one of
Compiling with one of
Compiling with one of Note that user-supplied Native codegen and LLVM codegen support for As can be surmised, the non-PI vs PIC vs PIC is complex and there are certainly other variants (e.g., The approach taken here is to make the default case follow the behavior of the C compiler (that was used to build the runtime) when compiling an executable. There may be (small) issues with downstream packaging and/or binary releases. In particular, if the C compiler used to build a package or binary release was not configured with Closes #191 |
Add
-native-pic {false,true}
and-pic-runtime {false,true}
expert options that can be used to override the target-determined default. Along with-cc-opt
,-llvm-lc-opt
, and-link-opt
, most configurations can be explicitly achieved:.s
->.o
-native-pic false
Default when target is considered to require PIC.
-native-pic true
Default when target is not considered to require PIC.
Not supported, in the sense that the native codegen's have no support for PIE vs PIC. Nonetheless, amd64-linux seems forgiving about linking
-native-pic true
object files with-pie
..c
->.o
Default when the target is not considered to require PIC;
cc
will be called with no-fPIC
,-fno-pic
,-fPIE
, or-fno-pie
option and, hence, the C compiler's default behavior will be followed.-cc-opt -fno-pic
Use to override the
-fPIC
added tocc
flags when the target is considered to require PIC. Also, even if the target is not considered to require PIC, the C compiler may be configured with--enable-default-pie
and an explicit-cc-opt -fno-pic
may be required to override the implicit-fPIE
of the C compiler's default behavior.-cc-opt -fPIC
Default when target is considered to require PIC. Note that if the C compiler is configured with
--enable-default-pie
, then this overrides the implicit-fPIE
of the C compiler's default behavior.-cc-opt -fPIE
.ll
->.o
Default when the target is not considered to require PIC;
llc
will be called with no-relocation-model
option.-llvm-llc-opt -relocation-model=static
Use to override the
-relocation-mode=pic
added tollc
flags when the target is considered to require PIC.-llvm-llc-opt -relocation-model=pic
Default when target is considered to require PIC
llc
has other-relocation-model
options; perhaps one corresponds to a C compiler's-fPIE
behavior..o
&.a
-> execc
will be called with either-lmlton
or-lmlton-pic
, depending on whether or not the target is considered to require PIC, and no-static
,-no-pie
, or-pie
option and, hence, the C compiler's default behavior will be followed.-pic-runtime false -link-opt -static
-pic-runtime true -link-opt -no-pie
Even if the target is not considered to require PIC, the C compiler may be configured with
--enable-default-pie
and an explicit-link-opt -no-pie
may be required to override the implicit-pie
of the C compiler's default behavior.-pic-runtime true -link-opt -pie
As can be surmised, the non-PI vs PIC vs PIC is complex and this is hardly a complete solution. However, in the absence of additional understanding and a clear design, a variety of explicit controls seems best.
Closes (albeit, incompletely) #191