clang download

Started by jcfuller, January 15, 2025, 06:11:51 AM

Previous topic - Next topic

MrBcx

James,

LLVM-18.1.8-win64.exe is the latest version that I've been using.

HIGH-Zen

I downloaded it too.
Windows 11 Pro
24H2

BCX Editor 3.67 (64-bit)
BCX 8.2.0 64-bit

If you try to compile GUI example "timestable.bas" you will get error:
Quoteunsupported option '-mwindows' for target 'x86_64-pc-windows-msvc'
you must remove -mwindows flag from Cl64w.bat (C:\bed64\Bat\CLANG)
Code for quick test:

'========================================================================
' Tiny Times Table by Kevin Diggins(1999) -- A BCX BASIC sample program
'========================================================================
GUI "TINY_TIMES_TABLE"
'========================================================================
MACRO  ID_Button1  = 101
MACRO  ID_Button2  = 102
MACRO  ID_Button3  = 103
MACRO  ID_Button4  = 104
MACRO  ID_Button5  = 105
MACRO  ID_Button6  = 106
MACRO  ID_Button7  = 107
MACRO  ID_Button8  = 108
MACRO  ID_Button9  = 109
MACRO  ID_Button10 = 110
MACRO  ID_Edit     = 200
MACRO  ID_Exit     = 300
'========================================================================
DIM    MainMenu   AS HMENU
DIM    FileMenu   AS HMENU
DIM    Form1      AS HWND
DIM    Edit1      AS CONTROL
DIM    Button[10] AS CONTROL
'========================================================================

SUB FORMLOAD
   Form1 = BCX_FORM("Tiny Times Table", 0, 0, 120, 170, WS_CAPTION|WS_POPUP)
   Edit1 = BCX_EDIT("", Form1, ID_Edit, 30, 5, 80, 140)

   FOR INTEGER i = 0 TO 9
     Button[i] = BCX_BUTTON(TRIM$(STR$(i + 1)), _
     Form1, 101 + i, 5, 5 + (i * 14), 20, 15)
   NEXT
   '========================================================================
   '                          Building Our Menu
   '========================================================================
   MainMenu = CreateMenu() ' CreateMenu returns a MENU HANDLE
   FileMenu = CreateMenu() ' CreateMenu returns a MENU HANDLE
   '========================================================================
   '                     Build the File Menu First
   '========================================================================
   AppendMenu(FileMenu,MF_STRING , ID_Exit  ,"E&xit")
   '========================================================================
   '       Build the Main Menu And Attach the Exit Menu to it and Activate
   '========================================================================
   InsertMenu( MainMenu, ID_Edit, MF_POPUP, FileMenu ,"Exit" )
   SetMenu    ( Form1, MainMenu )
   '========================================================================
   CENTER Form1
   SHOW   Form1
END SUB

BEGIN EVENTS
   SELECT CASE CBMSG
     '**********************
     CASE WM_COMMAND
     '**********************
     SELECT CASE CBCTL
       CASE ID_Button1 TO ID_Button10
       BuildTable(CBCTL-100)

       CASE ID_Exit
       PostQuitMessage(0)
     END SELECT
   END SELECT
END EVENTS

SUB BuildTable (A)
   LOCAL Buf$
   FOR INTEGER i = 1 TO 20
     Buf$ = Buf$ + "   " + STR$(A) + "  X " + STR$(i) + " = " + STR$(i * A) + CRLF$
   NEXT
   BCX_SET_TEXT(Edit1, Buf$)
END SUB

MrBcx

#3
Quote from: HIGH-Zen on January 15, 2025, 08:18:40 AM
I downloaded it too.
Windows 11 Pro
24H2

BCX Editor 3.67 (64-bit)
BCX 8.2.0 64-bit

If you try to compile GUI example "timestable.bas" you will get error:
Quoteunsupported option '-mwindows' for target 'x86_64-pc-windows-msvc'
you must remove -mwindows flag from Cl64w.bat (C:\bed64\Bat\CLANG)
Code for quick test:

'========================================================================
' Tiny Times Table by Kevin Diggins(1999) -- A BCX BASIC sample program
'========================================================================
GUI "TINY_TIMES_TABLE"
'========================================================================
MACRO  ID_Button1  = 101
MACRO  ID_Button2  = 102
MACRO  ID_Button3  = 103
MACRO  ID_Button4  = 104
MACRO  ID_Button5  = 105
MACRO  ID_Button6  = 106
MACRO  ID_Button7  = 107
MACRO  ID_Button8  = 108
MACRO  ID_Button9  = 109
MACRO  ID_Button10 = 110
MACRO  ID_Edit     = 200
MACRO  ID_Exit     = 300
'========================================================================
DIM    MainMenu   AS HMENU
DIM    FileMenu   AS HMENU
DIM    Form1      AS HWND
DIM    Edit1      AS CONTROL
DIM    Button[10] AS CONTROL
'========================================================================

SUB FORMLOAD
   Form1 = BCX_FORM("Tiny Times Table", 0, 0, 120, 170, WS_CAPTION|WS_POPUP)
   Edit1 = BCX_EDIT("", Form1, ID_Edit, 30, 5, 80, 140)

   FOR INTEGER i = 0 TO 9
     Button[i] = BCX_BUTTON(TRIM$(STR$(i + 1)), _
     Form1, 101 + i, 5, 5 + (i * 14), 20, 15)
   NEXT
   '========================================================================
   '                          Building Our Menu
   '========================================================================
   MainMenu = CreateMenu() ' CreateMenu returns a MENU HANDLE
   FileMenu = CreateMenu() ' CreateMenu returns a MENU HANDLE
   '========================================================================
   '                     Build the File Menu First
   '========================================================================
   AppendMenu(FileMenu,MF_STRING , ID_Exit  ,"E&xit")
   '========================================================================
   '       Build the Main Menu And Attach the Exit Menu to it and Activate
   '========================================================================
   InsertMenu( MainMenu, ID_Edit, MF_POPUP, FileMenu ,"Exit" )
   SetMenu    ( Form1, MainMenu )
   '========================================================================
   CENTER Form1
   SHOW   Form1
END SUB

BEGIN EVENTS
   SELECT CASE CBMSG
     '**********************
     CASE WM_COMMAND
     '**********************
     SELECT CASE CBCTL
       CASE ID_Button1 TO ID_Button10
       BuildTable(CBCTL-100)

       CASE ID_Exit
       PostQuitMessage(0)
     END SELECT
   END SELECT
END EVENTS

SUB BuildTable (A)
   LOCAL Buf$
   FOR INTEGER i = 1 TO 20
     Buf$ = Buf$ + "   " + STR$(A) + "  X " + STR$(i) + " = " + STR$(i * A) + CRLF$
   NEXT
   BCX_SET_TEXT(Edit1, Buf$)
END SUB


You must enable the Link Internal DPI Manifest File checkbox on the Build Dialog box



HIGH-Zen

#4
It looks like for target x86_64-pc-windows-msvc this flag is ignored anyway.
https://stackoverflow.com/questions/78622281/why-is-clang-linked-with-msvc-on-windows
Quote... The alternative target is x86_64-pc-windows-gnu. That will only work if you have gcc installed. ...
More info:
https://github.com/llvm/llvm-project/issues/69964

Robert

Quote from: HIGH-Zen on January 15, 2025, 08:18:40 AM
I downloaded it too.
Windows 11 Pro
24H2

BCX Editor 3.67 (64-bit)
BCX 8.2.0 64-bit

If you try to compile GUI example "timestable.bas" you will get error:
Quoteunsupported option '-mwindows' for target 'x86_64-pc-windows-msvc'
you must remove -mwindows flag from Cl64w.bat (C:\bed64\Bat\CLANG)

....


High-Zen:

Replace
-mwindows
with
-Wl,-subsystem:windows

MrBcx

Nice discovery ... I shall update the two BED Clang batch files with this. 

Now, CLANG no longer requires BED's resource file but  it will accept it

Thanks for the help Robert

HIGH-Zen

Yeah! I can confirm, that compiler flags are fixed now.  :)

Robert

Quote from: jcfuller on January 15, 2025, 06:11:51 AM
Kevin,
  Which file to download?
https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8

James
Hi James:

The LLVM / Clang release and download links are a mess.   :(

The latest downloads, currently LLVM 19.1.7, are at

https://github.com/llvm/llvm-project/releases

Regarding usage:

The Clang Compiler User's Manual (now at Version 20, always ahead of the mob) is at

https://clang.llvm.org/docs/UsersManual.html

quoting from

https://clang.llvm.org/

"Both a GCC-compatible compiler driver (clang) and an MSVC-compatible compiler driver (clang-cl.exe) are provided."

To build good clang batch files, an understanding of the difference between invoking clang.exe vs clang-cl.exe is important for expected results.

clang.exe

clang.exe Command-Line Options are listed at

https://clang.llvm.org/docs/UsersManual.html#command-line-options

clang-cl.exe

clang-cl.exe docs with Command-Line Options are at

https://clang.llvm.org/docs/UsersManual.html#clang-cl

But wait ! There's more ! You want both ? You can have both !

The "clang-cl.exe /clang:" Option

https://clang.llvm.org/docs/UsersManual.html#the-clang-option



MrBcx

#9
When visiting https://github.com/llvm/llvm-project/releases

you may need to click the view 59 more files option at the bottom of the Assets list to actually find the link to:

https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/LLVM-19.1.7-win64.exe


MrBcx

FYI

I just built my copy of BCX using 19.1.7 and then built my copy of BED using that version of BCX and compiled my copy of BED using 19.1.7

All went well
except for me needing to change one line of code in BED to overcome a clang loss-of-precision warning.


Robert

Quote from: MrBcx on January 16, 2025, 04:02:23 PM
When visiting https://github.com/llvm/llvm-project/releases

you may need to click the view 59 more files option at the bottom of the Assets list to actually find the link to:

https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/LLVM-19.1.7-win64.exe

If your Security Team gets on your case about installing an unsigned .exe, with no reputation, put together by unknown volunteers from only God knows where,

https://github.com/llvm/llvm-project/releases/download/lclang+llvm-19.1.7-x86_64-pc-windows-msvc.tar.xz

works just as well as

https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/LLVM-19.1.7-win64.exe

I unpack mine in my Downloads folder, change the name to LLVM and install in the UAC protected "Programs Files" folder.

There it can not be as easily tampered with by those pathetic sub-humans, usually histrionic egoists, whose only enjoyment comes from the schadenfreude of their miserable antics. I know ... sad but true.



jcfuller

Robert,
  Wow! Information OVERLOAD :)
I am updating my BcxAdp and I think now I'll just leave clang to the user.

I notice the bed clang batch files use clang++ ??

James


MrBcx

Quote from: jcfuller on January 17, 2025, 04:32:56 AM

I notice the bed clang batch files use clang++ ??

James

Did you forget that BCX emits code that requires a C++ compiler or a C compiler with C++ extensions
( LccWin32 / PellesC ) or the optional arg converter?

And did you also notice that you can build the 34 cpp demos found in BcxHelp, contributed by
Eric Brasseur, using BED with its CLANG batch files, along with practically every other console, gui, and dll
demo that isn't dependent on its own build.bat?  I know this because I did this.  It's called testing.

Not to mention that clang++ also builds non-trivial apps like building BED using BED and BED's clang batch file.

All of which seems like fairly compelling arguments for using clang++ in my BED batch files.  Now having said all that,
some may prefer or need to use clang as a straight C compiler.  Here is what ChatGPT summarizes about that:


The difference between using clang and clang++  lies in how the two commands handle the default language and linker behavior:
1. Default Language

    clang: Treats the input source files as C files by default unless specified otherwise (e.g., .cpp files or using flags like -x c++).
    clang++: Treats the input source files as C++ files by default.

2. Linking Behavior

    clang: Uses the C standard library (libc) and links against libraries appropriate for C programs.
    clang++: Links against the C++ standard library (libstdc++ or libc++, depending on your setup) and includes support for C++ runtime features.

3. Compiler Flags

    clang: Requires explicit flags if you want to enable C++ features (e.g., -std=c++17).
    clang++: Automatically enables C++ support and links the necessary libraries without needing additional flags.


    Use clang if you're compiling C programs or if you want explicit control over C++ language options and linking.
    Use clang++ when working with C++ programs, as it simplifies the process by automatically applying C++ settings and linking the appropriate libraries.
   





jcfuller

Kevin,
  I do know why you used clang++.
I changed from clang-cl to clang++ in my recent testing.
I commented because I don't think I saw any mention of clang++ in Robert's post or links.

James