Skip to content
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

Remove special case for -c dbg and -c opt #1129

Closed
guibou opened this issue Oct 17, 2019 · 5 comments
Closed

Remove special case for -c dbg and -c opt #1129

guibou opened this issue Oct 17, 2019 · 5 comments

Comments

@guibou
Copy link
Contributor

guibou commented Oct 17, 2019

When building with -c opt or -c dbg, rules_haskell changes the behavior as following:

  • -c opt: -O2 flag is added
  • -c dbg: a lot of stuffs are changed to enable Haskell debug.

I'm facing the following problems on a codebase with Haskell and C++ code.

  • We want to build the C++ code with optimization (so -c opt) and suddenly the Haskell code takes 2x more time to build
  • We want to build the C++ code with debug symboles (so -c dbg) and suddenly the Haskell code takes 15x more time to build (see Profiling is unecessary slow #438 )

We can also imagine context where we want to build C++ or Haskell code with profiling and optimization, this is not easily doable today.

I propose the following changes:

  • remove the special case for -c opt. If users want -O2, they can add it on compiler_flags based on configurations.
  • remove the special case for -c dbg and replace this by a flag on the haskell_toolchain or on haskell_library / haskell_binary.
@mboes
Copy link
Member

mboes commented Oct 17, 2019

We want to build the C++ code with optimization (so -c opt) and suddenly the Haskell code takes 2x more time to build

... and the C++ code likely also takes 2x more time to build. But isn't that exactly what you asked for in that case? i.e. "Ms compiler, please spend more time to generate better code"?

Today -c opt turns on -O2 for C++. What do you suggest -c opt mean for Haskell? The same thing as -c fastbuild?

@guibou
Copy link
Contributor Author

guibou commented Oct 17, 2019

First of all, the increase of build time with -O2 is not the same in C++ than it is in Haskell. For example, here I'm compiling a C++ file in -O0 in 0.110s, and in -O2 in 0.150s. In comparison a similar haskell file compiles in -O0 in 0.4s and in -O2 in 3.7s.

I propose to let the user choose based on configuration. Actually that's fine if you want to keep the -c opt and -c dbg behaviors, but we also need a way to do something different.

  • What if I want to build with profiling enabled AND optimizations?
  • What if I want to build my C++ with optimizations and debug symbols, but my Haskell without because I don't care about performances and I care more about my build time (in this context, I have 15 minutes build time transformed in 15x15minutes for a runtime of 5 seconds, 2 with optimizations).

@mboes
Copy link
Member

mboes commented Oct 18, 2019

The title of this issue is "Remove special case for -c dbg and -c opt". As far as I understand, concerning -c opt in particular, you are proposing to turn that into a no-op. Is that right? I find it hard to justify not having the same semantics as for C++ when these can be replicated exactly in the Haskell rules (as is the case for -c opt).

As for the questions in your previous comment, those sound like different feature requests to me.

@guibou
Copy link
Contributor Author

guibou commented Oct 18, 2019

Could you suggest a better title for the issue please?

@guibou
Copy link
Contributor Author

guibou commented Apr 29, 2020

Closed in favor of #1315 :

  • Per rule profiling configuration #1315 discuss a way to enable / disable profiling per rule or globally for all the haskell rules. This solves the -c dbg issue I'm having here.
  • Solving the -c opt issue is trivial: just pass -O0 or -O2 on the compiler_flags.

@guibou guibou closed this as completed Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants