GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2019-07-07T18:02:44Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/15848ghc builds cbits with -fPIC even when -fPIC is not passed to ghc on linux2019-07-07T18:02:44ZZejun Wughc builds cbits with -fPIC even when -fPIC is not passed to ghc on linuxghc assumes that on linux, C compiler (e.g. gcc) will build non-PIC object code when no `-fPIC` is passed. But this is no longer true for recent gcc version on some distributions. e.g.
```
$ uname -a
Linux watashi-arch32 4.18.5-arch1-1....ghc assumes that on linux, C compiler (e.g. gcc) will build non-PIC object code when no `-fPIC` is passed. But this is no longer true for recent gcc version on some distributions. e.g.
```
$ uname -a
Linux watashi-arch32 4.18.5-arch1-1.0-ARCH #1 SMP PREEMPT Tue Aug 28 20:45:30 CEST 2018 i686 GNU/Linux
$ gcc --version
gcc (GCC) 7.3.1 20180312
$ touch dummy.c
$ gcc -Q -v dummy.c 2>&1 | grep PIC
options enabled: -fPIC -fPIE -faggressive-loop-optimizations
```
We need pass `-fno-PIC` explicitly just like we have done for `-no-pie` (See #12759)
In particular, this results in 300+ ext-interp related tests to fail on i386 when built with a gcc that has `-fPIC` on by default, as we don't support loading non-PIC .o built from .c on i386. (See #15847, fix this bug will mitigate #15847)8.8.1Zejun WuZejun Wuhttps://gitlab.haskell.org/ghc/ghc/-/issues/15904hp2ps fail with parse error when the command args contains double quotes2019-07-07T18:02:30ZZejun Wuhp2ps fail with parse error when the command args contains double quotes```
watashi % cat test.hs
main = pure ()
watashi % ghc -prof -rtsopts test.hs
watashi % ./test '{"e": 2.72, "pi": 3.14}' +RTS -h
watashi % hp2ps test.hp
hp2ps: test.hp, line 1: integer must follow identifier
```
Manually open `test.hp` ...```
watashi % cat test.hs
main = pure ()
watashi % ghc -prof -rtsopts test.hs
watashi % ./test '{"e": 2.72, "pi": 3.14}' +RTS -h
watashi % hp2ps test.hp
hp2ps: test.hp, line 1: integer must follow identifier
```
Manually open `test.hp` and remove the `"`s in `JOB` will mitigate the problem.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Profiling |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"hp2ps fail with parse error when the command args contains double quotes","status":"New","operating_system":"","component":"Profiling","related":[],"milestone":"8.8.1","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":["hp2ps"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"{{{\r\nwatashi % cat test.hs\r\nmain = pure ()\r\nwatashi % ghc -prof -rtsopts test.hs\r\nwatashi % ./test '{\"e\": 2.72, \"pi\": 3.14}' +RTS -h\r\nwatashi % hp2ps test.hp\r\nhp2ps: test.hp, line 1: integer must follow identifier\r\n}}}\r\n\r\nManually open `test.hp` and remove the `\"`s in `JOB` will mitigate the problem.","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1Zejun WuZejun Wuhttps://gitlab.haskell.org/ghc/ghc/-/issues/16260Use of plugins causes different SafeHaskellMode returned for the module2019-07-07T18:00:46ZZejun WuUse of plugins causes different SafeHaskellMode returned for the moduleUse of plugins will mark safe inference as failed, even when the plugin does not modify anything. This can result in compile error when -XSafe is used. For example:
```
$ cat DefaultPlugin.hs
module DefaultPlugin (plugin) where
import G...Use of plugins will mark safe inference as failed, even when the plugin does not modify anything. This can result in compile error when -XSafe is used. For example:
```
$ cat DefaultPlugin.hs
module DefaultPlugin (plugin) where
import GhcPlugins
plugin = defaultPlugin
$ cat B.hs
{-# OPTIONS_GHC -fplugin DefaultPlugin #-}
module B (answer) where
answer = 42
$ cat A.hs
{-# LANGUAGE Safe #-}
module A (main) where
import B
main = print answer
$ ...
A.hs:4:1: error:
B: Can't be safely imported! The module itself isn't safe.
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.7 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Use of plugins causes -XSafe to fail","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.7","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Use of plugins will mark safe inference as failed, even when the plugin does not modify anything. This can result in compile error when -XSafe is used. For example:\r\n\r\n{{{\r\n$ cat DefaultPlugin.hs\r\nmodule DefaultPlugin (plugin) where\r\nimport GhcPlugins\r\nplugin = defaultPlugin\r\n\r\n$ cat B.hs\r\n{-# OPTIONS_GHC -fplugin DefaultPlugin #-}\r\nmodule B (answer) where\r\nanswer = 42\r\n\r\n$ cat A.hs\r\n{-# LANGUAGE Safe #-}\r\nmodule A (main) where\r\nimport B\r\nmain = print answer\r\n\r\n$ ...\r\nA.hs:4:1: error:\r\n B: Can't be safely imported! The module itself isn't safe.\r\n}}}","type_of_failure":"OtherFailure","blocking":[]} -->8.8.1Zejun WuZejun Wuhttps://gitlab.haskell.org/ghc/ghc/-/issues/16737cpp is not run when building .c or .cpp files2023-10-05T09:35:28ZZejun Wucpp is not run when building .c or .cpp files# Summary
C pre-processor is not run and `-D` or `-optP` flags are not respected when building `.c` or `.cpp` files.
# Steps to reproduce
```bash
$ cat test.c
#ifndef TEST
#define TEST 0
#endif
#include <stdio.h>
int main(void) {
pr...# Summary
C pre-processor is not run and `-D` or `-optP` flags are not respected when building `.c` or `.cpp` files.
# Steps to reproduce
```bash
$ cat test.c
#ifndef TEST
#define TEST 0
#endif
#include <stdio.h>
int main(void) {
printf("%d\n", TEST);
return 0;
}
$ ghc -DTEST=9 test.c -no-hs-main && ./a.out
0
```
or
```bash
$ mkdir -p x && touch x/x.h
$ echo '#include "x.h"' > y.c
$ ghc -Ix -c y.c
$ ghc -optP=-Ix -c y.c
y.c:1:10: error:
fatal error: x.h: No such file or directory
#include "x.h"
^~~~~
|
1 | #include "x.h"
| ^
compilation terminated.
`gcc' failed in phase `C Compiler'. (Exit code: 1)
```
# Expected behavior
Output `9` for the first example.
Both `ghc -Ix -c y.c` and `ghc -optP=-Ix -c y.c` work in the second example.
This is because we don't run cpp for `Cc`, `Ccxx`, `Cobjc` and `Cobjcxx` phase and we probably should do so.
For `HCc` phase, we usually run cpp in previous phase and probably don't want to run it again.8.8.1Zejun WuZejun Wu