<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJzVV9uO2zYQ_Rr5ZSBBF9trP_jBa8ftAmlTNEn7uKCokcUsJQokZa_79R2S8q693bQpEjSoIdASL8M5Zy4clqo6rX5EKRWspYzyTZRuo3Qd2g-NMEAPAyPaXiJo7LWqBo4aaq1aUIMG1vdScGaF6qAchKyiYlwe5Wu4g4YdEFT5CbmFWpAQ33DV9vRfwVHYRg0W3vXY_fQL1JLtzeVyq09gFXCNzCLgI_oVYBsEVqoXollXAS2jx00Kb1eSE_CYNJpBWsLWkWgpugdArZVOLsGLBK--o3kaHq46oySelZwC8kbRtjlJg5aJLsoXUb6E6OaWNrKD7iCNilv63rpZEBVvoFYq4X3_LINL1u2j_JYeiPl5HL78F-UFsKoS3R4UAW77ABga1AiVQkNq3VjgbDAIJUp1DJhfV8HtryBW7gXiepR4fokt03u0Jiq23aG3j_Np3B1EJVjMh4pdktYdPLs1s0w6JYs1bNQgK-iU9XqSCfphtB4pGOU72_bU0r4xq2Y58oQPpeP0Jkj0WsZZ4UQFAPQybkNO1ToXqNmTa5HHCEKtKoSMNlg49PHBeZRBpM0PKrguGeyFmS9hrAOx1BsfqIG9OKB59vN_8I9vRSwpfsEBHFAbF3RZkaTJqO4Hv95R8riY39PyoXvo1LGLiZ_hMd53wzmyKZ4qaIkX6Wb3yojHMHTXGTIW8bcVnlsyxr6vDf2VZZ9ww03CKbR2xlTUUvT7If-Rp3kWZ5kbtGyP9_hoUXdMuhkiiL3fc05TkjxJY_NwkuwBaVDKQxsHHPGDNL20TiZZ3Wu0UwMZlZNlReWSwA-bDYzigu2-TssxFemXWk6TRTKLG2aO6DLj7kLzw6c_ji6_7KQowwi1I-M9vyA734UVAch7lJSqyDP_twg2T0ZoKYEKt5hUTyi9RdO0nU9f4Py7ScGqm4_b9bek4otdzgWU650meXyi6NuTy22eY4qm_zXfHJnuKA-4148hroL-46oEnNCk8VmO-u9_e_Pr-7t3P1M0Z1k6TRNYGzO0LpO444vworFghr5X2rH1tHmaUK6a3ca_n6PXKzsOR7Nt0MwdJt81OIlET46qa6lYFZdkUPJCd8bF9tQj4aYc95zSGmVs_Nm8lG_GHPhq5vPHhBNyTqCDHTuujox6xooaE-UKmcv-fImEPxwlQJsHVSEm0OoYt8IYssoIwPy39L7miCO94VjzfLoC4wIPLrIsWySucKLTLGaaN2Da-5sU4rffzSco0OGzrH-DeuBK3HetB96VB6EGI09UoNK5BOTgoEUFqoah65CjMYzqVqeEK5V9IUaOZ13tyZnBBG4J5B2w1gM3A9Voog7jwpel2FWkcYlUPdNOmlKHBYmM8oVLHR4ooXDMlbS0pbL8QPNdsRcVu-sanhETJ0UBlk2qVVEtiyWbsIGqbr3qNaMS4GEyaLlqrO19TZPvnAcRV0OZEIOjtc9Gp51cve0chJIZOk-Z5ct5MWlW5c2yvimzLF8WfFalZVZNC854tSiKokrT5UQyKjzNilIb-XSHR_AiXJzNtpOv10CsyD3yNEuLbD4r8jQpZzOOxXxWLtkUq5zT8YNUoMvEyUmU3k_0yossB7p0TFMpjDXPg4yywr5D9AqThlZY6T_CjYK64C1Z2OXzYJBjQw7sbyq-7_KuEm4pxpv76u5zdT35lwGRErCMPQXExPOx8mT8CUe6Yac>52963</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [OpenMP] Linking error when creating exe with the objects not compiled with OpenMP flags : Could not open input file '/tmp/foo-0b9a1a.cubin'
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pramodk
      </td>
    </tr>
</table>

<pre>
    Hello All,

This is a simple reproducer from our application build:
* I have object file file compiled without OpenMP flags
* I try to create exe with the above object file and **with** OpenMP flags. This results into link error.

i.e.

```console
$ echo "int main() { return 0; } " > foo.cpp
$ clang++ -c foo.cpp                                           # adding openmp flags here doesn't cause below error
$ clang++ foo.o -o foo -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda

nvlink fatal   : Could not open input file '/tmp/foo-ad52ec.cubin'
clang-13: error: nvlink command failed with exit code 1 (use -v to see invocation)
```

Adding `-v` gives:

```console
$ clang++ foo.o -o foo -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -v
clang version 13.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /gpfs/bbp.cscs.ch/ssd/apps/bsd/2021-11/stage_externals/install_gcc-11.2.0-skylake/llvm-13.0.0-klsplt/bin
Found candidate GCC installation: /gpfs/bbp.cscs.ch/ssd/apps/bsd/2021-11/stage_compilers/install_gcc-4.8.5-haswell/gcc-11.2.0-vjzwth/lib/gcc/x86_64-pc-linux-gnu/11.2.0
Selected GCC installation: /gpfs/bbp.cscs.ch/ssd/apps/bsd/2021-11/stage_compilers/install_gcc-4.8.5-haswell/gcc-11.2.0-vjzwth/lib/gcc/x86_64-pc-linux-gnu/11.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /gpfs/bbp.cscs.ch/ssd/apps/bsd/2021-11/stage_externals/install_gcc-11.2.0-skylake/cuda-11.4.2-yopegt, version 11.2
clang-13: warning: Unknown CUDA version. cuda.h: CUDA_VERSION=11040. Assuming the latest supported version 10.1 [-Wunknown-cuda-version]
 "/gpfs/bbp.cscs.ch/ssd/apps/bsd/2021-11/stage_externals/install_gcc-11.2.0-skylake/llvm-13.0.0-klsplt/bin/clang-offload-bundler" -type=o -targets=host-x86_64-unknown-linux-gnu,openmp-nvptx64-nvidia-cuda -inputs=foo.o -outputs=/tmp/foo-f5a3fe.o,/tmp/foo-29e202.cubin -unbundle -allow-missing-bundles
 "/gpfs/bbp.cscs.ch/ssd/apps/bsd/2021-11/stage_externals/install_gcc-11.2.0-skylake/cuda-11.4.2-yopegt/bin/nvlink" -o /tmp/foo-e81118.out -v -arch sm_70 -L/gpfs/bbp.cscs.ch/ssd/apps/bsd/2021-11/stage_externals/install_gcc-11.2.0-skylake/llvm-13.0.0-klsplt/lib /tmp/foo-29e202.cubin
nvlink fatal   : Could not open input file '/tmp/foo-29e202.cubin'
clang-13: error: nvlink command failed with exit code 1 (use -v to see invocation)
```

Obviously I can get rid of unnecessary linker flags in this case. But I am not sure if this is intended behaviour. At least the error could be improved here?

Thank you!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVV9uO2zYQ_Rr5ZSBBF18f_OC143aBtimapH1cUNTIYpYSBZKy1_36Dkl5194mbYoGDWoIsiySwzO3w-NSVef19yilgo2UUb6N0l2UbsL9fSMM0MXAiLaXCBp7raqBo4ZaqxbUoIH1vRScWaE6KAchq6gYl0f5Bu6hYUcEVX5EbqEWZMTfuGp7-q7gJGyjBgtve-x-_BlqyQ7mernVZ7AKuEZmEfAJ_QqwDQIr1SvTrKuAltHlJoWnG8sJeJ80mkFa8q0j01J0j4BaK51cOy8SvPkdzdNwcdUZJfECcgrIG0Xb5mQNWia6KF9G-QqixR1tZAfdQRoVd_R752ZBVLyBWqmE9_2LDS5Zd4jyO7og5pdx-PJPlBfAqkp0B1DkcNsHh6FBjVApNARrYYGzwSCUKNUp-PxpCG5_BbFyDxDXo8XLQ2yZPqA1UbHrjr19mk_j7igqwWI-VOw6aN3RR7dmlkkHstjAVg2ygk5Zj5NS0A9j9ghglO9t29Od9o1ZNcuRJ3woXUwXwaJHGWeFMxUcoIdxGyqq1pVAzZ5LiypGkNeqQshog6XzPj66ijKItPlRhdKlhL1K87UbmxBYehsf6QYHcUTzUud_Ux9fK7AE_CoGcERtXNNlRZImI9z3fr0LydNy_kDLh-6xU6cupvgMT_GhGy6dTf1UQUtxkW52r4x4CkP3naFkUfx2wseWknHoa0NfZdkn3HCTcGqtvTEV3an7_ZD_kad5FmeZG7TsgA_4ZFF3TLoZIph9OHBOU5I8SWPzeJbsEWlQymMbBz_iR2l6aZ1NyrpHtFcDJZVTZkXlSOC77RZGcyF3_w7lSEX6NcppskxmccPMC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