-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Parse all command line options in repl.c #9482
Conversation
586b9e1
to
eb575ba
Compare
While you're at it, documentation of these is duplicated across several different places, |
this seems good. +1 one thing to be aware of is that some of the arguments, such as |
@vtjnash good point, I couldn't replicate all previous behavior with how command line options were processed so it would be useful if others test this out to see if I broke something. |
cd1ac6b
to
f32430e
Compare
Nice one. |
59a8448
to
8301aa6
Compare
Rebased and squashed. I consolidated all options into a single struct as talked about. The old |
9ac4e71
to
8cfc435
Compare
The tests on Windows should pass now. |
|
||
-O, --optimize | ||
Run time-intensive code optimizations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the separate line here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, maybe I found it easier to read at the time?
8cfc435
to
ef382d0
Compare
Needs a rebase already? |
|
||
void parse_opts(int *argcp, char ***argvp) | ||
{ | ||
static char* shortopts = "+H:hJ:C:O"; | ||
enum { machinefile = 300, | ||
color, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no tabs whenever you rebase this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks. I have to change my Vim defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that #9732 might get merged before this and touches the same code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, @jakebolewski.
072b017
to
31d683d
Compare
Ok, I rebased just rebased. It needs some review as it touches a lot of code and I'm unsure if shoving everything into one struct is the cleanest way to do this. |
global process_options | ||
function process_options(opts::JLOptions, args::Vector{UTF8String}) | ||
if !isempty(args) && (arg = first(args); arg[1] == '-' && in(arg, reqarg)) | ||
println(STDERR, "julia: option `$arg` is missing an argument") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't we do this by checking the return value of getopt_long? http://man7.org/linux/man-pages/man3/getopt.3.html#RETURN_VALUE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be possible if the long option struct array was an exported global.
aesthetics (ignore, more or less)
other than my one inline comment, the actual code LGTM. lots of repetition but i guess that is unavoidable here. it would be nice if we could store all of the text-based/non-hot longopts in a dictionary, but i guess that would be harder to use (or not available at all when needed) from some parts of the C code. |
Bump |
9450, he has been rebasing it too many times I don't want to add to his pain :-) |
9450 merged. |
See also #10226 – argument parsing should stop at |
The c library that we use for unix |
How feasible is just moving all of the option parsing into Julia? Most of the REPL is in Julia these days so it seems like it shouldn't be too crazy to do that. |
I don't think too feasible at the moment. How do you turn off boundschecking for generated julia code that is being executed to parse the option to turn off boundschecking? |
Moving things to Julia is the opposite direction from what this PR does. And there's a bootstrapping problem for the flags that control compiler options, which is a good chunk of them. Note that we use the system version of getopt everywhere except in the (currently broken) MSVC build. |
@tkelman says that system getopt is used by default. Linux: The special argument "--" forces an end of option-scanning regardless of the scanning mode Is there an overall policy for how cross-platform issue should be handled in Julia? e.g. my usual rules for a non-GUI cross-platform system would be:
The alternatives are:
|
@samoconnor everything you describe is what we use libuv for... |
True, libuv is used (and seems like a decent choice) for network and IO stuff, but there is still a lot of #ifdef OS_WINDOWS elsewhere.
|
Well going out of your way to have fewer ifdefs if you don't deem Windows an "important platform" is an option for some projects. Cygwin is not an option for Julia since Cygwin doesn't implement any asynchronous IO required by libuv. For things that libuv doesn't cover, like a different set of headers being available, libc functions like |
@tkelman ... that all sounds reasonable. I think that it's important to have clear rules on which layers are allowed to talk to which other layers. (apologies to @jakebolewski for going so far off topic on your P.R.) |
We'd actually rather remove our posix assumptions as much as possible. Ideally libuv should stand between us and either posix or win32 for as much as it can. There are plenty of places that it can't do the job completely though, and llvm doesn't abstract away the OS to the extent that would allow us to clean up codegen, debuginfo, ffi, etc. The new ORC JIT API's that are being worked on in 3.7 might be nicer in this respect, I'm not sure? I did some quick comparisons and we have fewer Windows ifdefs than cmake or CPython, but evidently a bit more than either LLVM or luajit (or I was just searching for the wrong defines in those projects). Julia's C core is pretty small by language implementation standards, but it tends to be grouped by functionality rather than having centralized platform differences consolidated into a handful of headers or source files. |
I believe that LLVM separates a lot of it's host specific code into separate files (including autogenerated tblgen #include files), so that fewer ifdef's can cover more code. I don't really care how many ifdef's are needed for the C code. My goal is to largely eliminate the need for them in user code inside of Julia, by providing a user interface that can be consistently implemented across platform. this effort is greatly assisted by libuv, since it provides a consistent interface for dealing with a variety of platform-specific issues (generally related to I/O). |
31d683d
to
a7dad31
Compare
- consolidate all compiler / cmdline options into jl_options_t struct in julia.h - add options.jl to base/ with an immutable type JLOptions that reflects the jl_options_t struct - add --procs=<n> command line flag (equivalent to -p <n>) - add --history-file={yes|no} and --startup-file={yes|no} cmdline opts - --worker command line arguments changed to --worker, --worker=default, or --worker=custom - deprecate -f, -F, --no-startup, --no-history-file cmdline flags - add tests for cmdline arguments in test/cmdlineargs.jl - modify test/Makefile and tests to use long command line option, add command line argument tests to runtests.jl - update relevant docs in the manual and manpages
3a2c582
to
25b89e8
Compare
Ok, rebased. @amitmurthy I had to change |
Parse all command line options in repl.c
OK. Nice work on the cleanup. |
startup = false | ||
end | ||
# load ~/.julia_history file | ||
no_history_file = bool(opts.historyfile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a !
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched this to history_file=true/false
which follows other changes in this PR.
Addresses #9384. Currently the options that are not in
jl_compileropts_t
are stored into a newjl_options_t
struct. This struct is then loaded when processing the command line options inbase/client.jl
. This PR adds some sanity check tests for command line arguments as well.I think it would be better to rename
jl_compileropts_t
and just have one option struct for all command line arguments (and api to query the arguments from Julia).I've deprecated
--no-history-file
and--no-startup
flags in favor of--history-file={yes|no}
and--startup-file={yes|no}
so all command line options have a similar structure.