Visual Studio linker download

Windows specific forum
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Visual Studio linker download

Post by skywalk »

Most answers state up to 5 concurrent developers before requiring a paid license for commercial use.
I may be guessing, but that would include most PB users?
Are there many teams of 5+ developers using PB?
There are also income limits of $1 million for the commercial product. I can only dream :mrgreen:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Visual Studio linker download

Post by Fred »

chi wrote: Thu Apr 25, 2024 4:26 pm @Fred: Why don't you use LLVM instead? It's open source and both clang and lld-link work great with PB.
Did you get executable as small than with link.exe ?
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: Visual Studio linker download

Post by chi »

Fred wrote: Thu Apr 25, 2024 4:39 pm
chi wrote: Thu Apr 25, 2024 4:26 pm @Fred: Why don't you use LLVM instead? It's open source and both clang and lld-link work great with PB.
Did you get executable as small than with link.exe ?
I don't see why size matters in this regard, but there is a small difference ofc :)

1line MessageBox:

Code: Select all

[GCC]  "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\pbGcc.exe" -O3 -fno-tree-vrp -freorder-blocks-algorithm=simple -fno-schedule-insns -fno-schedule-insns2 -fno-strict-aliasing -fsigned-char -Wno-discarded-qu
        alifiers -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj "purebasic.c" -save-temps
        Time variable                                   usr           sys          wall           GGC
         phase setup                        :   0.01 (100%)  1363k (100%)
         TOTAL                              :   0.01         1363k
         pb_llrint PB_EndFunctions WinMain SYS_Quit
        Analyzing compilation unit
        Performing interprocedural optimizations
         <*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes> <remove_symbols> <targetclone> <free-fnsummary> <emutls>Streaming LTO
         <whole-program> <profile_estimate> <icf> <devirt> <cp> <sra> <fnsummary> <inline> <pure-const> <modref> <free-fnsummary> <static-var> <single-use>Assembling functions:
         <simdclone> PB_EndFunctions WinMain SYS_Quit
        Time variable                                   usr           sys          wall           GGC
         phase setup                        :   0.01 ( 22%)  1336k ( 78%)
         phase opt and generate             :   0.02 ( 70%)   220k ( 13%)
         callgraph functions expansion      :   0.01 ( 57%)   168k ( 10%)
         initialize rtl                     :   0.01 ( 26%)    12k (  1%)
         TOTAL                              :   0.02         1721k
        exitcode: 0
··································································
[RC]   "D:\Program Files\PureBasic6.10(x64)\Compilers\pbRC.exe" "C:\Users\chi\AppData\Local\Temp\PureBasic16440953\PureBasic.rc" /Fo"C:\Users\chi\AppData\Local\Temp\PureBasic16440953\PureBasic.res"
        exitcode: 0
··································································
[LINK] "D:\Program Files\PureBasic6.10(x64)\Compilers\vc\msLink.exe" /NOLOGO /FORCE:MULTIPLE /OUT:"E:\WinData\Desktop\mb1.exe" /SUBSYSTEM:Windows /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\PureLibraries\Windows\
        Libraries" /NODEFAULTLIB /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\Compilers" PureBasic.obj SystemBase.lib StringUtility.lib UnicodeFunctions.lib libcmt.lib libcpmt.lib libucrt.lib libvcruntime.lib KERNEL32.lib
         USER32.lib GDI32.lib COMDLG32.lib ADVAPI32.lib COMCTL32.lib OLEAUT32.lib "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\libgcc.a"  Requester.lib Desktop.lib FileSystem.lib Date.lib "D:\Program Files\PureBasic6
        .10(x64)\compilers/objectmanager.lib" SimpleList.lib "D:\Program Files\PureBasic6.10(x64)\compilers/stringmanagerc.lib"  OLE32.LIB Shell32.LIB Shlwapi.LIB Ole32.LIB kernel32.lib  PureBasic.res
        exitcode: 0
··································································
142 KB (145.408 bytes)

Code: Select all

[CLANG] "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\Clang.exe" -O3 -fno-strict-aliasing -fsigned-char -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj "purebasic.c" -Wno-
        parentheses-equality -Wno-unused-value -Wno-missing-prototype-for-cc -Wno-return-type -save-temps
        exitcode: 0
··································································
[RC]   "D:\Program Files\PureBasic6.10(x64)\Compilers\pbRC.exe" "C:\Users\chi\AppData\Local\Temp\PureBasic16468843\PureBasic.rc" /Fo"C:\Users\chi\AppData\Local\Temp\PureBasic16468843\PureBasic.res"
        exitcode: 0
··································································
[LINK] "D:\Program Files\PureBasic6.10(x64)\Compilers\vc\lld-link.exe" /NOLOGO /FORCE:MULTIPLE /OUT:"E:\WinData\Desktop\mb2.exe" /SUBSYSTEM:Windows /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\PureLibraries\Wind
        ows\Libraries" /NODEFAULTLIB /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\Compilers" PureBasic.obj SystemBase.lib StringUtility.lib UnicodeFunctions.lib libcmt.lib libcpmt.lib libucrt.lib libvcruntime.lib KERNEL
        32.lib USER32.lib GDI32.lib COMDLG32.lib ADVAPI32.lib COMCTL32.lib OLEAUT32.lib "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\libgcc.a"  Requester.lib Desktop.lib FileSystem.lib Date.lib "D:\Program Files\Pu
        reBasic6.10(x64)\compilers/objectmanager.lib" SimpleList.lib "D:\Program Files\PureBasic6.10(x64)\compilers/stringmanagerc.lib"  OLE32.LIB Shell32.LIB Shlwapi.LIB Ole32.LIB kernel32.lib  PureBasic.res
        exitcode: 0
··································································
146 KB (150.016 bytes)

~7000line app:

Code: Select all

[GCC]  "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\pbGcc.exe" -O3 -fno-tree-vrp -freorder-blocks-algorithm=simple -fno-schedule-insns -fno-schedule-insns2 -fno-strict-aliasing -fsigned-char -Wno-discarded-qu
        alifiers -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj "purebasic.c" -save-temps
        Time variable                                   usr           sys          wall           GGC
         phase setup                        :   0.04 ( 97%)  1653k (100%)
         TOTAL                              :   0.04         1653k
         pb_llrint f_comateclass_getdateproperty f_gosci_stylenextsymbolxxx f_comateclass_createenumeration f_comatesinkclass_gettypeinfocount f_comateclass_getcomobject f_comateclass_getcontainerhwnd f_gosci_scintillacallbackxxx f_adjustcurrentprocessprivilege f_comateclass_getobjecteventparam f_gosci_addkeywordsxxx f_comateclass_release f_comate_internal_preparestatement f_gosci_settext f_resetini f_comateenumclass_reset f_comateclass_setproperty f_gosci_isnumberxxx f_comateclass_internal_seterror f_comateclass_getstringeventparam f_setrights f_comatesinkclass_addref f_gosci_clear f_getprocessinfo f_systraycallback f_gosci_isseparatorxxx f_catchexeicon f_gosci_setstylecolors f_comatesinkclass_queryinterface f_comatesinkclass_gettypeinfo f_comatesinkclass_invoke f_comate_wrapcomobject f_pbosl_process_init f_gosci_setstylefont f_gosci_processcodecompletioncalltipsxxx f_comateclass_setdesigntimemode f_comate_freestatementhandle f_comate_getobject f_getwindowtext f_gosci_create f_gosci_getkeywordinfo f_disablefocusrect f_gosci_getnumberoflines f_comateclass_seteventhandler f_setmenuicons f_comate_internal_checknumeric f_examineprocesses f_comatesinkclass_release f_saveini f_comateclass_getobjectproperty f_comateclass_internal_invokeplus f_gosci_setmarginwidth f_comatesinkclass_getidsofnames f_comate_createobject f_comateclass_invoke f_rearrangemem f_comate_delsinkpropscallback f_gosci_restylelinesxxx f_comateplus_compilesubobjectinvokation f_gosci_getlinetext f_comateclass_getrealeventparam f_freestructurestring f_wndcallbacksc f_gosci_setfont f_comateenumclass_release f_enabletooltips f_comate_getlasterrorcode f_editini f_comateclass_internal_invokeidispatch f_parentitemtext f_comateplus_tokenisecommand f_gosci_stylelinexxx f_comateclass_getintegerproperty f_enumthreadwindows f_comateclass_utility_makebstr f_getdesktopinfo f_comateclass_setpropertyref f_comateenumclass_getnextvariant f_hidenlh f_comateclass_iseventparampassedbyref f_gosci_free f_gosci_adddelimiter f_comateclass_getvariantproperty f_treeviewexpandsublevel f_comate_internal_escapestring f_gosci_autosizelinenumbermarginxxx f_comateenumclass_getnextobject f_comateclass_getintegereventparam f_comate_internal_freestatementhandle f_pbosl_process_end f_comateclass_getstringproperty f_gosci_setattribute f_comateclass_getrealproperty f_writepreferencestr f_gosci_addkeywords PB_EndFunctions WinMain SYS_Quit
        Analyzing compilation unit
        Performing interprocedural optimizations
         <*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes> <remove_symbols> <targetclone> <free-fnsummary> <emutls>Streaming LTO
         <whole-program> <profile_estimate> <icf> <devirt> <cp> <sra> <fnsummary> <inline> <pure-const> <modref> <free-fnsummary> <static-var> <single-use>Assembling functions:
         <simdclone> f_comatesinkclass_gettypeinfocount f_comatesinkclass_addref f_comatesinkclass_gettypeinfo f_comateenumclass_release f_gosci_getkeywordinfo f_gosci_isseparatorxxx f_comateclass_utility_makebstr f_comatesinkclass_invoke f_comatesinkclass_getidsofnames f_comate_delsinkpropscallback f_comatesinkclass_queryinterface f_comateclass_release f_catchexeicon f_disablefocusrect f_comatesinkclass_release f_gosci_addkeywordsxxx.constprop f_comateclass_internal_seterror.constprop.isra f_comateenumclass_reset f_comateenumclass_getnextvariant f_comateclass_getcontainerhwnd f_comateclass_getcomobject f_comateenumclass_getnextobject f_comateclass_getstringeventparam f_comateclass_getrealeventparam f_comateclass_getobjecteventparam f_comateclass_getintegereventparam f_comateclass_seteventhandler f_comateclass_setdesigntimemode f_comateclass_iseventparampassedbyref f_comateclass_internal_invokeidispatch.constprop.isra f_setrights.constprop.isra f_examineprocesses.constprop f_gosci_autosizelinenumbermarginxxx.isra f_gosci_setstylefont.constprop.isra f_getdesktopinfo.isra f_getwindowtext.isra f_systraycallback f_hidenlh.constprop.isra f_comateclass_internal_invokeplus f_comateclass_setpropertyref f_comateclass_setproperty f_comateclass_getvariantproperty f_comateclass_getstringproperty f_comateclass_getrealproperty f_comateclass_getobjectproperty f_comateclass_createenumeration f_comateclass_getdateproperty f_comateclass_invoke f_comateclass_getintegerproperty f_gosci_stylenextsymbolxxx f_gosci_restylelinesxxx.isra f_gosci_settext.constprop.isra f_gosci_processcodecompletioncalltipsxxx.isra f_gosci_scintillacallbackxxx f_hidenlh.isra f_getprocessinfo.isra PB_EndFunctions WinMain SYS_Quit
        Time variable                                   usr           sys          wall           GGC
         phase setup                        :   0.01 (  0%)  1336k (  3%)
         phase parsing                      :   0.08 (  6%)  5815k ( 15%)
         phase opt and generate             :   1.23 ( 93%)    31M ( 82%)
         callgraph construction             :   0.02 (  1%)  3922k ( 10%)
         callgraph optimization             :   0.01 (  1%)  4864  (  0%)
         callgraph functions expansion      :   1.03 ( 79%)    20M ( 55%)
         callgraph ipa passes               :   0.14 ( 11%)  5065k ( 13%)
         ipa function summary               :   0.01 (  1%)   274k (  1%)
         ipa inlining heuristics            :   0.01 (  0%)   900k (  2%)
         cfg cleanup                        :   0.02 (  1%)   227k (  1%)
         trivially dead code                :   0.01 (  1%)     0  (  0%)
         df scan insns                      :   0.02 (  2%)  2832  (  0%)
         df reaching defs                   :   0.01 (  1%)     0  (  0%)
         df live regs                       :   0.07 (  5%)     0  (  0%)
         df live&initialized regs           :   0.02 (  2%)     0  (  0%)
         df use-def / def-use chains        :   0.01 (  0%)     0  (  0%)
         df reg dead/unused notes           :   0.04 (  3%)   487k (  1%)
         register information               :   0.01 (  0%)     0  (  0%)
         alias analysis                     :   0.01 (  1%)   892k (  2%)
         alias stmt walking                 :   0.01 (  1%)    11k (  0%)
         preprocessing                      :   0.02 (  1%)   268k (  1%)
         parser (global)                    :   0.02 (  2%)  2729k (  7%)
         parser function body               :   0.03 (  3%)  2553k (  7%)
         inline parameters                  :   0.01 (  1%)   273k (  1%)
         integration                        :   0.01 (  1%)  1157k (  3%)
         tree gimplify                      :   0.02 (  2%)  2418k (  6%)
         tree CFG construction              :   0.01 (  0%)   990k (  3%)
         tree CFG cleanup                   :   0.02 (  1%)    41k (  0%)
         tree copy propagation              :   0.01 (  0%)  2464  (  0%)
         tree PTA                           :   0.06 (  5%)   501k (  1%)
         tree SSA rewrite                   :   0.01 (  0%)   898k (  2%)
         tree SSA incremental               :   0.01 (  1%)   458k (  1%)
         tree operand scan                  :   0.00 (  0%)  1553k (  4%)
         dominator optimization             :   0.05 (  4%)   492k (  1%)
         backwards jump threading           :   0.04 (  3%)   273k (  1%)
         tree CCP                           :   0.03 (  3%)    90k (  0%)
         tree PRE                           :   0.04 (  3%)   641k (  2%)
         tree FRE                           :   0.03 (  2%)   419k (  1%)
         tree forward propagate             :   0.01 (  1%)    47k (  0%)
         tree conservative DCE              :   0.01 (  1%)  2824  (  0%)
         tree aggressive DCE                :   0.01 (  1%)   285k (  1%)
         complete unrolling                 :   0.01 (  0%)   246k (  1%)
         tree slp vectorization             :   0.01 (  1%)  1386k (  4%)
         tree iv optimization               :   0.01 (  1%)   245k (  1%)
         dominance computation              :   0.03 (  2%)     0  (  0%)
         expand                             :   0.02 (  2%)  3170k (  8%)
         forward prop                       :   0.02 (  1%)    11k (  0%)
         CSE                                :   0.03 (  2%)    73k (  0%)
         dead store elim1                   :   0.01 (  1%)   176k (  0%)
         loop init                          :   0.01 (  1%)   821k (  2%)
         CPROP                              :   0.03 (  2%)   516k (  1%)
         PRE                                :   0.01 (  1%)    18k (  0%)
         CSE 2                              :   0.02 (  1%)    36k (  0%)
         branch prediction                  :   0.01 (  0%)    68k (  0%)
         combiner                           :   0.04 (  3%)   525k (  1%)
         integrated RA                      :   0.08 (  6%)  3269k (  8%)
         LRA non-specific                   :   0.02 (  2%)    89k (  0%)
         LRA virtuals elimination           :   0.01 (  0%)   135k (  0%)
         LRA reload inheritance             :   0.01 (  0%)  5792  (  0%)
         LRA create live ranges             :   0.01 (  1%)  8040  (  0%)
         reload CSE regs                    :   0.03 (  2%)   272k (  1%)
         load CSE after reload              :   0.01 (  0%)  1320  (  0%)
         thread pro- & epilogue             :   0.01 (  1%)   183k (  0%)
         peephole 2                         :   0.01 (  1%)    58k (  0%)
         hard reg cprop                     :   0.01 (  0%)  3408  (  0%)
         reorder blocks                     :   0.01 (  0%)   132k (  0%)
         shorten branches                   :   0.01 (  0%)     0  (  0%)
         final                              :   0.02 (  1%)    43k (  0%)
         variable output                    :   0.01 (  1%)  2200  (  0%)
         rest of compilation                :   0.03 (  2%)   221k (  1%)
         remove unused locals               :   0.01 (  0%)     0  (  0%)
         address taken                      :   0.01 (  0%)     0  (  0%)
         TOTAL                              :   1.31           38M
        exitcode: 0
··································································
[RC]   "D:\Program Files\PureBasic6.10(x64)\Compilers\pbRC.exe" "C:\Users\chi\AppData\Local\Temp\PureBasic16666734\PureBasic.rc" /Fo"C:\Users\chi\AppData\Local\Temp\PureBasic16666734\PureBasic.res"
        exitcode: 0
··································································
[LINK] "D:\Program Files\PureBasic6.10(x64)\Compilers\vc\msLink.exe" /NOLOGO /FORCE:MULTIPLE /OUT:"E:\WinData\Desktop\nlh1.exe" /SUBSYSTEM:Windows /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\PureLibraries\Windo
        ws\Libraries" /NODEFAULTLIB /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\Compilers" PureBasic.obj SystemBase.lib StringUtility.lib UnicodeFunctions.lib libcmt.lib libcpmt.lib libucrt.lib libvcruntime.lib KERNEL3
        2.lib USER32.lib GDI32.lib COMDLG32.lib ADVAPI32.lib COMCTL32.lib OLEAUT32.lib "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\libgcc.a"  Thread.lib Sort.lib Scintilla.lib Requester.lib Process.lib Cipher.lib 
        Preference.lib Math.lib Library.lib Gadget.lib DragDrop.lib ClipboardImage.lib System.lib Window.lib Menu.lib SysTray.lib FileSystem.lib Date.lib File.lib Event.lib Map.lib Desktop.lib Array.lib 2DDrawing.lib Ima
        ge.lib LinkedList.lib AlphaImage.lib ImagePluginBMP.lib ImagePlugin.lib VectorDrawing.lib String.lib Memory.lib Font.lib "D:\Program Files\PureBasic6.10(x64)\compilers/objectmanagerthread.lib" SimpleList.lib "D:\
        Program Files\PureBasic6.10(x64)\compilers/stringmanagercthread.lib"  imm32.LIB uuid.LIB pbscintilla.LIB OLE32.LIB SHELL32.LIB OLEAUT32.LIB ADVAPI32.LIB OLE32.LIB SHELL32.LIB COMCTL32.LIB UUID.LIB VERSION.LIB UUI
        D.LIB SHELL32.LIB WINMM.LIB PSAPI.LIB SHELL32.LIB Shell32.LIB Shlwapi.LIB Ole32.LIB GdiPlus.LIB advapi32.lib comctl32.lib user32.lib kernel32.lib ole32.lib oleaut32.lib shell32.lib uxtheme.lib "/RELEASE" "/OPT:RE
        F" "/NXCOMPAT" "/HIGHENTROPYVA" "/DYNAMICBASE" "/LARGEADDRESSAWARE" "/EMITPOGOPHASEINFO" "atl.lib"  PureBasic.res
        exitcode: 0
··································································
1,13 MB (1.188.352 bytes)

Code: Select all

[CLANG] "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\Clang.exe" -O3 -fno-strict-aliasing -fsigned-char -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj "purebasic.c" -Wn
        o-parentheses-equality -Wno-unused-value -Wno-missing-prototype-for-cc -Wno-return-type -save-temps
        exitcode: 0
··································································
[RC]   "D:\Program Files\PureBasic6.10(x64)\Compilers\pbRC.exe" "C:\Users\chi\AppData\Local\Temp\PureBasic16690703\PureBasic.rc" /Fo"C:\Users\chi\AppData\Local\Temp\PureBasic16690703\PureBasic.res"
        exitcode: 0
··································································
[LINK] "D:\Program Files\PureBasic6.10(x64)\Compilers\vc\lld-link.exe" /NOLOGO /FORCE:MULTIPLE /OUT:"E:\WinData\Desktop\nlh2.exe" /SUBSYSTEM:Windows /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\PureLibraries\Win
        dows\Libraries" /NODEFAULTLIB /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\Compilers" PureBasic.obj SystemBase.lib StringUtility.lib UnicodeFunctions.lib libcmt.lib libcpmt.lib libucrt.lib libvcruntime.lib KERNE
        L32.lib USER32.lib GDI32.lib COMDLG32.lib ADVAPI32.lib COMCTL32.lib OLEAUT32.lib "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\libgcc.a"  Thread.lib Sort.lib Scintilla.lib Requester.lib Process.lib Cipher.li
        b Preference.lib Math.lib Library.lib Gadget.lib DragDrop.lib ClipboardImage.lib System.lib Window.lib Menu.lib SysTray.lib FileSystem.lib Date.lib File.lib Event.lib Map.lib Desktop.lib Array.lib 2DDrawing.lib I
        mage.lib LinkedList.lib AlphaImage.lib ImagePluginBMP.lib ImagePlugin.lib VectorDrawing.lib String.lib Memory.lib Font.lib "D:\Program Files\PureBasic6.10(x64)\compilers/objectmanagerthread.lib" SimpleList.lib "D
        :\Program Files\PureBasic6.10(x64)\compilers/stringmanagercthread.lib"  imm32.LIB uuid.LIB pbscintilla.LIB OLE32.LIB SHELL32.LIB OLEAUT32.LIB ADVAPI32.LIB OLE32.LIB SHELL32.LIB COMCTL32.LIB UUID.LIB VERSION.LIB U
        UID.LIB SHELL32.LIB WINMM.LIB PSAPI.LIB SHELL32.LIB Shell32.LIB Shlwapi.LIB Ole32.LIB GdiPlus.LIB advapi32.lib comctl32.lib user32.lib kernel32.lib ole32.lib oleaut32.lib shell32.lib uxtheme.lib "/RELEASE" "/OPT:
        REF" "/NXCOMPAT" "/HIGHENTROPYVA" "/DYNAMICBASE" "/LARGEADDRESSAWARE" "/EMITPOGOPHASEINFO" "atl.lib"  PureBasic.res
        exitcode: 0
··································································
1,13 MB (1.190.400 bytes)
Et cetera is my worst enemy
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Visual Studio linker download

Post by Fred »

Thanks for the nice comparison ! Seems like lld-link is using Apache license so I will give it a try for the next major PB version 8)
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: Visual Studio linker download

Post by chi »

Fred wrote: Thu Apr 25, 2024 10:13 pm Thanks for the nice comparison ! Seems like lld-link is using Apache license so I will give it a try for the next major PB version 8)
Sounds great! The biggest impact on filesize btw would be by using lld-link instead of polink when creating dll's...

~2200line dll:

Code: Select all

[GCC]  "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\pbGcc.exe" -O3 -fno-tree-vrp -freorder-blocks-algorithm=simple -fno-schedule-insns -fno-schedule-insns2 -fno-strict-aliasing -fsigned-char -Wno-discarded-qu
        alifiers -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj "purebasic.c" -save-temps
        Time variable                                   usr           sys          wall           GGC
         phase setup                        :   0.01 (100%)  1452k (100%)
         TOTAL                              :   0.01         1452k
         pb_llrint f__bufferedpaintuninit f_wm_nccreate f__endbufferedpaint f_shdsubproc f__setwindowtheme f__dwmflush f_skin_ninja_vsync f_winsubproc f_attachprocess f_updateshadowwindow f_setwindows11fix f_cbtproc f_hcbt_createwnd f__dwmsetwindowattribute f_skin_ninja_rtl f__dwmiscompositionenabled f_init f_exit f_createbitmap_zero f__dwmextendframeintoclientarea f_wm_ctlcolor f_detachprocess f__beginbufferedpaint f_wm_ncpaint f_wm_erasebkgnd f_createbgeraseimage f_skin_ninja_init f_wm_nccalcsize f_createbitmap_rgba f__bufferedpaintinit f_flipbuffers_ f__setwindowcompositionattribute PB_EndFunctions DllMain pb_dllinit SYS_Quit
        Analyzing compilation unit
        Performing interprocedural optimizations
         <*free_lang_data> <visibility> <build_ssa_passes> <opt_local_passes> <remove_symbols> <targetclone> <free-fnsummary> <emutls>Streaming LTO
         <whole-program> <profile_estimate> <icf> <devirt> <cp> <sra> <fnsummary> <inline> <pure-const> <modref> <free-fnsummary> <static-var> <single-use>Assembling functions:
         <simdclone> f__endbufferedpaint f__setwindowtheme f__dwmsetwindowattribute f__dwmiscompositionenabled f__beginbufferedpaint f__bufferedpaintinit f__setwindowcompositionattribute f_createbitmap_rgba.constprop f_createbitmap_rgba.constprop f__dwmextendframeintoclientarea f_hcbt_createwnd.constprop.isra f_wm_ncpaint.isra f_wm_nccreate.isra f__bufferedpaintuninit f__dwmflush f_createbgeraseimage.isra f_cbtproc f_updateshadowwindow.isra f_shdsubproc f_winsubproc f_skin_ninja_vsync f_attachprocess f_skin_ninja_rtl f_detachprocess f_skin_ninja_init PB_EndFunctions DllMain SYS_Quit
        Time variable                                   usr           sys          wall           GGC
         phase setup                        :   0.01 (  2%)  1336k ( 11%)
         phase parsing                      :   0.02 (  5%)  1577k ( 13%)
         phase opt and generate             :   0.33 ( 93%)  9319k ( 76%)
         callgraph functions expansion      :   0.29 ( 81%)  6700k ( 55%)
         callgraph ipa passes               :   0.04 ( 10%)  1261k ( 10%)
         cfg cleanup                        :   0.01 (  3%)    69k (  1%)
         df reaching defs                   :   0.01 (  2%)     0  (  0%)
         df live regs                       :   0.02 (  4%)     0  (  0%)
         df reg dead/unused notes           :   0.01 (  3%)   149k (  1%)
         parser function body               :   0.01 (  3%)   920k (  8%)
         tree CFG cleanup                   :   0.01 (  2%)  8656  (  0%)
         tree PTA                           :   0.02 (  6%)    96k (  1%)
         dominator optimization             :   0.02 (  5%)   183k (  2%)
         backwards jump threading           :   0.01 (  3%)   157k (  1%)
         tree PRE                           :   0.01 (  3%)   210k (  2%)
         tree FRE                           :   0.01 (  2%)   139k (  1%)
         tree forward propagate             :   0.01 (  1%)    16k (  0%)
         tree slp vectorization             :   0.01 (  1%)   443k (  4%)
         dominance computation              :   0.01 (  2%)     0  (  0%)
         expand                             :   0.01 (  2%)  1094k (  9%)
         forward prop                       :   0.01 (  1%)  2328  (  0%)
         CSE                                :   0.01 (  3%)    27k (  0%)
         loop init                          :   0.01 (  1%)   204k (  2%)
         CPROP                              :   0.01 (  2%)   201k (  2%)
         combiner                           :   0.01 (  3%)   178k (  1%)
         integrated RA                      :   0.02 (  5%)  1227k ( 10%)
         LRA non-specific                   :   0.01 (  2%)    24k (  0%)
         reload CSE regs                    :   0.01 (  2%)    98k (  1%)
         hard reg cprop                     :   0.01 (  1%)  1704  (  0%)
         rest of compilation                :   0.01 (  3%)   115k (  1%)
         TOTAL                              :   0.36           11M
        exitcode: 0
··································································
[RC]   "D:\Program Files\PureBasic6.10(x64)\Compilers\pbRC.exe" "C:\Users\chi\AppData\Local\Temp\PureBasic26939265\PureBasic.rc" /Fo"C:\Users\chi\AppData\Local\Temp\PureBasic26939265\PureBasic.res"
        exitcode: 0
··································································
[LINK] "D:\Program Files\PureBasic6.10(x64)\Compilers\pbLink.exe" /FORCE:MULTIPLE /DLL /DEF:PureBasic.def /OUT:"E:\WinData\Documents\PureProjects\demo.17\demo.dll" /LIBPATH:"D:\Program Files\PureBasic
        6.10(x64)\PureLibraries\Windows\Libraries" /NODEFAULTLIB /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\Compilers" PureBasic.obj SystemBase.lib StringUtility.lib UnicodeFunctions.lib libcmt.lib libcpmt.lib libucrt
        .lib libvcruntime.lib KERNEL32.lib USER32.lib GDI32.lib COMDLG32.lib ADVAPI32.lib COMCTL32.lib OLEAUT32.lib "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\libgcc.a"  System.lib ImagePluginPNG.lib 2DDrawing.li
        b Image.lib LinkedList.lib AlphaImage.lib ImagePluginBMP.lib ImagePlugin.lib VectorDrawing.lib String.lib Memory.lib Font.lib "D:\Program Files\PureBasic6.10(x64)\compilers/objectmanager.lib" SimpleList.lib "D:\P
        rogram Files\PureBasic6.10(x64)\compilers/stringmanagerc.lib"  SHELL32.LIB WINMM.LIB PSAPI.LIB zlib.LIB libpng.LIB GdiPlus.LIB comctl32.lib gdi32.lib uxtheme.lib kernel32.lib user32.lib "/SUBSYSTEM:Windows,5.0" "
        /RELEASE" "/OPT:REF" "/NXCOMPAT" "/HIGHENTROPYVA" "/DYNAMICBASE" "/LARGEADDRESSAWARE" "/EMITPOGOPHASEINFO"  PureBasic.res
        POLINK: warning: Unrecognized option '/EMITPOGOPHASEINFO'; ignored.
        POLINK: warning: Section '.gfids$y' is not supported; ignored.
        POLINK: warning: Unrecognized option '/GUARDSYM:__C_specific_handler,S'; ignored.
        POLINK: warning: Unrecognized option '/GUARDSYM:__CxxFrameHandler3,S'; ignored.
        POLINK: warning: Unrecognized option '/GUARDSYM:__CxxFrameHandler4,S'; ignored.
        POLINK: warning: Unrecognized option '/GUARDSYM:__CxxFrameHandler2,S'; ignored.
        POLINK: warning: Unrecognized option '/GUARDSYM:__CxxFrameHandler,S'; ignored.
        POLINK: warning: Unrecognized option '/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:msvcrt.lib'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:msvcrtd.lib'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:libcmtd.lib'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:vcruntime.lib'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:vcruntimed.lib'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:libvcruntimed.lib'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:ucrtd.lib'; ignored.
        POLINK: warning: Unrecognized option '/disallowlib:libucrtd.lib'; ignored.
        POLINK: warning: Unrecognized option '/GUARDSYM:longjmp,S'; ignored.
        Creating object: E:\WinData\Documents\PureProjects\demo.17\demo.exp
        Creating library: E:\WinData\Documents\PureProjects\demo.17\demo.lib
        exitcode: 0
··································································
[LIB]  "D:\Program Files\PureBasic6.10(x64)\Compilers\pbLib.exe" /MACHINE:X64 /DEF:PureBasic.def /OUT:"E:\WinData\Documents\PureProjects\demo.17\demo.lib"
        exitcode: 0
··································································
893 KB (914.432 bytes)

Code: Select all

[CLANG] "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\Clang.exe" -O3 -fno-strict-aliasing -fsigned-char -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj "purebasic.c" -Wno-
        parentheses-equality -Wno-unused-value -Wno-missing-prototype-for-cc -Wno-return-type -save-temps
        exitcode: 0
··································································
[RC]   "D:\Program Files\PureBasic6.10(x64)\Compilers\pbRC.exe" "C:\Users\chi\AppData\Local\Temp\PureBasic27020484\PureBasic.rc" /Fo"C:\Users\chi\AppData\Local\Temp\PureBasic27020484\PureBasic.res"
        exitcode: 0
··································································
[LINK] "D:\Program Files\PureBasic6.10(x64)\Compilers\lld-link.exe" /FORCE:MULTIPLE /DLL /DEF:PureBasic.def /OUT:"E:\WinData\Documents\PureProjects\demo.17\demo.dll" /LIBPATH:"D:\Program Files\PureBasic
        6.10(x64)\PureLibraries\Windows\Libraries" /NODEFAULTLIB /LIBPATH:"D:\Program Files\PureBasic6.10(x64)\Compilers" PureBasic.obj SystemBase.lib StringUtility.lib UnicodeFunctions.lib libcmt.lib libcpmt.lib libucrt.l
        ib libvcruntime.lib KERNEL32.lib USER32.lib GDI32.lib COMDLG32.lib ADVAPI32.lib COMCTL32.lib OLEAUT32.lib "D:\Program Files\PureBasic6.10(x64)\Compilers\gcc\libgcc.a"  System.lib ImagePluginPNG.lib 2DDrawing.lib Im
        age.lib LinkedList.lib AlphaImage.lib ImagePluginBMP.lib ImagePlugin.lib VectorDrawing.lib String.lib Memory.lib Font.lib "D:\Program Files\PureBasic6.10(x64)\compilers/objectmanager.lib" SimpleList.lib "D:\Program
         Files\PureBasic6.10(x64)\compilers/stringmanagerc.lib"  SHELL32.LIB WINMM.LIB PSAPI.LIB zlib.LIB libpng.LIB GdiPlus.LIB comctl32.lib gdi32.lib uxtheme.lib kernel32.lib user32.lib "/SUBSYSTEM:Windows,5.0" "/RELEASE
        " "/OPT:REF" "/NXCOMPAT" "/HIGHENTROPYVA" "/DYNAMICBASE" "/LARGEADDRESSAWARE" "/EMITPOGOPHASEINFO"  PureBasic.res
        exitcode: 0
··································································
[LIB]  "D:\Program Files\PureBasic6.10(x64)\Compilers\llvm-lib.exe" /MACHINE:X64 /DEF:PureBasic.def /OUT:"E:\WinData\Documents\PureProjects\demo.17\demo.lib"
        /DEF:PureBasic.def: no such file or directory
        exitcode: 1
··································································
426 KB (436.736 bytes)

hints:
.) When creating a .dll, the corresponding .lib file is already created with the linker, so it's not necessary to call lib.exe to create it.
.) When you create an .exe on x86, you get "lld-link: error: /safeseh: c:\purebasic\svn\v6.10\build\x86\systembase\InitString_WASM.obj is not compatible with SEH". I had to add "/SAFESEH:NO" to the linker
.) I also tried llvm-rc.exe, but you have to convert PB_Resources.rc from UTF-16 BOM to UTF-8 BOM and remove the © symbol (possibly others too). Somehow the "modern theme support" manifest isn't working anymore


edit: Sorry for hijacking your thread, fryquez ;)
Et cetera is my worst enemy
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: Visual Studio linker download

Post by fryquez »

Glad to see I not the only one who intercept PB's build chain and uses clang instead of GCC.

Added download script for the UCRT lib's, but it is a bit bigger download (232 MB).

Code: Select all

EnableExplicit

UseZipPacker()

Procedure UnPackDelete_Libs(sVSIX.s, sOut.s)
  
  Protected sPattern.s = "*/libcmt.lib;*/libcpmt.lib;*/libvcruntime.lib;*/vcruntime.lib;*/msvcprt.lib;*/msvcrt.lib"
    
  Protected iCount, hPack = OpenPack(#PB_Any, sVSIX)
  If hPack
    If ExaminePack(hPack)
      While NextPackEntry(hPack)        
        If PathMatchSpec_(PackEntryName(hPack), @sPattern)
          If UncompressPackFile(hPack, sOut + GetFilePart(PackEntryName(hPack)), PackEntryName(hPack)) <> -1
            iCount + 1
          EndIf
        EndIf
      Wend
    EndIf
    ClosePack(hPack)
  EndIf
  
  DeleteFile(sVSIX)
  
  ProcedureReturn iCount
  
EndProcedure

Structure FILE_IN_CABINET_INFO
  NameInCabinet.i
  FileSize.l
  Win32Error.l
  DosDate.w
  DosTime.w
  DosAttribs.w
  FullTargetName.s{260}
EndStructure

Structure UnPack_UCRT
  sPath.s
  iCount.l
EndStructure

Procedure UnPack_UCRT(*pv.UnPack_UCRT, Notification, *INFO.FILE_IN_CABINET_INFO, Param2)
  
  Protected *File.String = *INFO
  
  If Notification = $11
    
    Select *File\s
        
      Case "fil846174c605e081bb24562265bd765205"
        *INFO\FullTargetName = *pv\sPath + "x86\libucrt.lib"
        *pv\iCount + 1
      Case "fil0ffacac4b2fc995d06d98b84a2539bf7"
        *INFO\FullTargetName = *pv\sPath + "x86\ucrt.lib"
        *pv\iCount + 1        
      Case "filcd9bca91d11c02b5bbda06ff40c55404"
        *INFO\FullTargetName = *pv\sPath + "x64\libucrt.lib"
        *pv\iCount + 1
      Case "fil9880b801b7a55120f35d0b81c561ed78"
        *INFO\FullTargetName = *pv\sPath + "x64\ucrt.lib"
        *pv\iCount + 1        
      Case "filf8c3dec5fc7bb981741dd8d9c058f091"
        *INFO\FullTargetName = *pv\sPath + "arm64\libucrt.lib"
        *pv\iCount + 1
      Case "fil697b6a1050db23b589f46c02c81b6201"
        *INFO\FullTargetName = *pv\sPath + "arm64\ucrt.lib"
        *pv\iCount + 1
        
      Default
        ProcedureReturn 2 ; #FILEOP_SKIP
        
    EndSelect
    
    ProcedureReturn 1
  EndIf
  
  ProcedureReturn 0
  
EndProcedure

Procedure DownLoad_VcLibs(sDir.s = "")
  
  Protected sTempDir.s = GetTemporaryDirectory()
  
  If sDir = ""
    Protected sDesktop.s = Space(#MAX_PATH), pidl
    If SHGetSpecialFolderLocation_ (0, #CSIDL_DESKTOP, @pidl) = #NOERROR
      SHGetPathFromIDList_(pidl, @sDesktop)
      CoTaskMemFree_(pidl)
      sDir = sDesktop
    EndIf    
  EndIf
  
  If Right(sDir, 1) <> "\" : sDir + "\" : EndIf
  
  sDir + "VC_Libs\"
  Protected sOut_64.s, sOut_86.s, sOut_AA.s
  sOut_64 = sDir + "x64\" 
  sOut_86 = sDir + "x86\"
  sOut_AA = sDir + "arm64\"
  SHCreateDirectory_(0, @sOut_64)
  SHCreateDirectory_(0, @sOut_86)
  SHCreateDirectory_(0, @sOut_AA)
    
  Debug "Loading 1 / 6"
  ReceiveHTTPFile("https://download.microsoft.com/" +
                  "download/3/b/d/3bd97f81-3f5b-4922-b86d-dc5145cd6bfe/" +
                  "windowssdk/Installers/6ee7bbee8435130a869cf971694fd9e2.cab",
                  sTempDir + "x86.cab")
  
  Debug "Loading 2 / 6"
  ReceiveHTTPFile("https://download.microsoft.com/" +
                  "download/3/b/d/3bd97f81-3f5b-4922-b86d-dc5145cd6bfe/" +
                  "windowssdk/Installers/a1e2a83aa8a71c48c742eeaff6e71928.cab",
                  sTempDir + "x64.cab")
  
  Debug "Loading 3 / 6"
  ReceiveHTTPFile("https://download.microsoft.com/" +
                  "download/3/b/d/3bd97f81-3f5b-4922-b86d-dc5145cd6bfe/" +
                  "windowssdk/Installers/78fa3c824c2c48bd4a49ab5969adaaf7.cab",
                  sTempDir + "arm64.cab")
  
  
  Protected UnPack_UCRT.UnPack_UCRT
  UnPack_UCRT\sPath = sDir
  SetupIterateCabinet_(sTempDir + "x86.cab", 0, @UnPack_UCRT(), @UnPack_UCRT)
  DeleteFile(sTempDir + "x86.cab")
  SetupIterateCabinet_(sTempDir + "x64.cab", 0, @UnPack_UCRT(), @UnPack_UCRT)
  DeleteFile(sTempDir + "x64.cab")
  SetupIterateCabinet_(sTempDir + "arm64.cab", 0, @UnPack_UCRT(), @UnPack_UCRT)
  DeleteFile(sTempDir + "arm64.cab")
  
  Debug "Loading 4 / 6"
  
  ReceiveHTTPFile("https://download.visualstudio.microsoft.com/"+
                  "download/pr/402fe58b-c490-402c-8ce4-33ca5c80d984/" +
                  "fbe0faaf668317eb6ae0315eb27a914165f5356fdcedffd2d56196b0c1b94a7a/" +
                  "Microsoft.VC.14.39.17.9.CRT.x86.OneCore.Desktop.base.vsix", 
                  sTempDir + "CRT.x86.Desktop.vsix")
  
  Debug "Loading 5 / 6"
  
  ReceiveHTTPFile("https://download.visualstudio.microsoft.com/"+
                  "download/pr/402fe58b-c490-402c-8ce4-33ca5c80d984/" +
                  "d998b3d5b5e4772c19ddc938f415ef3207cbd13c8be7df28e326964d783c421f/" +
                  "Microsoft.VC.14.39.17.9.CRT.x64.OneCore.Desktop.base.vsix", 
                  sTempDir + "CRT.x64.Desktop.vsix")
  
  Debug "Loading 6 / 6"
  
  ReceiveHTTPFile("https://download.visualstudio.microsoft.com/"+
                  "download/pr/402fe58b-c490-402c-8ce4-33ca5c80d984/"+ 
                  "dc85acf9bfa415119b8936965b406915cfcec8f990902306217221597b552dc2/" +
                  "Microsoft.VC.14.39.17.9.CRT.ARM64.OneCore.Desktop.base.vsix",
                  sTempDir + "CRT.arm64.Desktop.vsix")
  
  
  UnPack_UCRT\iCount + UnPackDelete_Libs(sTempDir + "CRT.x86.Desktop.vsix", sOut_86)
  UnPack_UCRT\iCount + UnPackDelete_Libs(sTempDir + "CRT.x64.Desktop.vsix", sOut_64)
  UnPack_UCRT\iCount + UnPackDelete_Libs(sTempDir + "CRT.arm64.Desktop.vsix", sOut_AA)
  
  
  
  Protected flags = #PB_MessageRequester_Error
  If UnPack_UCRT\iCount = 24
    flags = #PB_MessageRequester_Info
  EndIf
  MessageRequester("Download finished", Str(UnPack_UCRT\iCount) + " from 24 files received!", flags)
  ShellExecute_(0, 0, @sDir, 0, 0, #SW_SHOWDEFAULT)
  
EndProcedure

DownLoad_VcLibs()
Last edited by fryquez on Mon Apr 29, 2024 10:46 am, edited 2 times in total.
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Visual Studio linker download

Post by ChrisR »

Thanks fryquez, for OpenPack CRT*.vsix files, I had to add UseZipPacker()
And the 18 libs are downloaded and extracted, Top 8)
Axolotl
Enthusiast
Enthusiast
Posts: 798
Joined: Wed Dec 31, 2008 3:36 pm

Re: Visual Studio linker download

Post by Axolotl »

If you are like me and don't understand anything....
To whom it may concern.
helpful explanation for me: Universal CRT deployment
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Visual Studio linker download

Post by ChrisR »

I don't know much about but I tries with the dynamic link against the UCRT and static against the VCRuntime
I copied the 6 x64 libs and the 6 x86 libs into their respective folders: "\PureLibraries\Windows\Libraries"
In debug mode, on all examples, the debugged quit unexpectedly!
Once compiled, it worked on several examples but for my app, it crashed on OpenPack() (it looks good if I comment on this part), ex:

Code: Select all

Import "/NODEFAULTLIB:libucrt.lib" : EndImport
Import "ucrt.lib" : EndImport

UseZipPacker()
If OpenPack(0, #PB_Compiler_Home + "themes/SilkTheme.zip")
  If ExaminePack(0)
    While NextPackEntry(0)
      ListPackEntry.s + PackEntryName(0) + ", "
    Wend
  EndIf
  ClosePack(0)
  MessageRequester("ListPackEntry", ListPackEntry)
EndIf
fryquez
Enthusiast
Enthusiast
Posts: 391
Joined: Mon Dec 21, 2015 8:12 pm

Re: Visual Studio linker download

Post by fryquez »

Interesting, working here with all my projects (at least without debugger).
Maybe some PB libs are not compatible with it yet.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Visual Studio linker download

Post by Fred »

ChrisR wrote: Sun Apr 28, 2024 5:24 pm I don't know much about but I tries with the dynamic link against the UCRT and static against the VCRuntime
I copied the 6 x64 libs and the 6 x86 libs into their respective folders: "\PureLibraries\Windows\Libraries"
In debug mode, on all examples, the debugged quit unexpectedly!
Once compiled, it worked on several examples but for my app, it crashed on OpenPack() (it looks good if I comment on this part), ex:

Code: Select all

Import "/NODEFAULTLIB:libucrt.lib" : EndImport
Import "ucrt.lib" : EndImport

UseZipPacker()
If OpenPack(0, #PB_Compiler_Home + "themes/SilkTheme.zip")
  If ExaminePack(0)
    While NextPackEntry(0)
      ListPackEntry.s + PackEntryName(0) + ", "
    Wend
  EndIf
  ClosePack(0)
  MessageRequester("ListPackEntry", ListPackEntry)
EndIf
Did you use the ms linker for your tests?
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Visual Studio linker download

Post by ChrisR »

I tried with MS VS linker or without it, it crashed in both cases with Packer
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: Visual Studio linker download

Post by chi »

Fred wrote: Sun Apr 28, 2024 6:36 pm
ChrisR wrote: Sun Apr 28, 2024 5:24 pm I don't know much about but I tries with the dynamic link against the UCRT and static against the VCRuntime
I copied the 6 x64 libs and the 6 x86 libs into their respective folders: "\PureLibraries\Windows\Libraries"
In debug mode, on all examples, the debugged quit unexpectedly!
Once compiled, it worked on several examples but for my app, it crashed on OpenPack() (it looks good if I comment on this part), ex:

Code: Select all

Import "/NODEFAULTLIB:libucrt.lib" : EndImport
Import "ucrt.lib" : EndImport

UseZipPacker()
If OpenPack(0, #PB_Compiler_Home + "themes/SilkTheme.zip")
  If ExaminePack(0)
    While NextPackEntry(0)
      ListPackEntry.s + PackEntryName(0) + ", "
    Wend
  EndIf
  ClosePack(0)
  MessageRequester("ListPackEntry", ListPackEntry)
EndIf
Did you use the ms linker for your tests?
It works with link.exe if you remove libucrt.lib from the commandline before passing it to the linker... The line /NODEFAULTLIB:libucrt.lib has no effect (also checked with -verbose).

Code: Select all

CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
  Import "/SAFESEH:NO" : EndImport
CompilerEndIf

Import "ucrt.lib" : EndImport

UseZipPacker()
If OpenPack(0, #PB_Compiler_Home + "themes/SilkTheme.zip")
  If ExaminePack(0)
    While NextPackEntry(0)
      ListPackEntry.s + PackEntryName(0) + ", "
    Wend
  EndIf
  ClosePack(0)
  MessageRequester("ListPackEntry", ListPackEntry)
EndIf
Et cetera is my worst enemy
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: Visual Studio linker download

Post by ChrisR »

Tested and confirmed with this Fake Link.exe, even in debug mode, thanks chi

Code: Select all

; -----------------------------------------------------------------------------
; Link.pb - Test only: remove libucrt.lib
; Get Compilation via a fake Link.exe:
; -----------------------------------------------------------------------------
; Compile it as Link.exe
; Then In PureBasic_6.10_x64\Compilers\vc, rename Link.exe to Link_real.exe and copy your Fake Link.exe in PureBasic_6.0_x64\Compilers\vc 
; Do not forget to restore Link_real.exe to Link.exe when you no longer need this hack
; -----------------------------------------------------------------------------
EnableExplicit

#UseCmdlines = #False   ; #True | #False (Compil via cmdlines)

Define CountParam, ProgramParam$, linkParam$, I 
Define Gcc, Link, Output$, Error$
Define CompilerPath$ = GetPathPart(ProgramFilename())
Define gccParam$ = "-O0 -g -fsigned-char -Wno-discarded-qualifiers -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj purebasic.c "
;Define gccParam$ = "-O2 -fno-tree-vrp -freorder-blocks-algorithm=simple -fno-schedule-insns -fno-schedule-insns2 -fno-strict-aliasing -fsigned-char -Wno-discarded-qualifiers -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-conversion -c -o PureBasic.obj purebasic.c" 

If FileSize(CompilerPath$ + "link_real.exe") > 0
  CompilerPath$ = Left(CompilerPath$, Len(CompilerPath$)- 3)
  CountParam = CountProgramParameters()
  For I=0 To CountParam-1
    ProgramParam$ = ProgramParameter(I)
    Select ProgramParam$
      Case "libucrt.lib"
      Default
        linkParam$ + ProgramParam$ + " "
    EndSelect   
  Next
  
  CompilerIf #UseCmdlines
    SetClipboardText("Cd /D " + GetCurrentDirectory() +#CRLF$+ 
                     "PATH=%PATH%;" + CompilerPath$ + ";" + CompilerPath$ + "gcc\" + ";" + CompilerPath$ + "vc\" +#CRLF$+
                     "gcc.exe " + gccParam$ +#CRLF$+
                     "link_real.exe " + linkParam$ +#CRLF$+ "")
    MessageRequester("Compilation Cmdlines", "Compilation cmdlines copied to the clipboard." +#CRLF$+#CRLF$+ "To be used in cmd.exe before closing this window", #PB_MessageRequester_Ok | #PB_MessageRequester_Info)
  CompilerElse
    Gcc = RunProgram(CompilerPath$ + "gcc\gcc.exe", gccParam$, GetCurrentDirectory(), #PB_Program_Open | #PB_Program_Read | #PB_Program_Error )
    If Gcc
      While ProgramRunning(Gcc)
        If AvailableProgramOutput(Gcc)
          Output$ + ReadProgramString(Gcc) + #CRLF$
          Error$ + ReadProgramError(Gcc) + #CRLF$
        EndIf
      Wend
      If ProgramExitCode(Gcc) <> 0 
        Error$ + ReadProgramError(Gcc) + #CRLF$
        MessageRequester("Error " +  GetCurrentDirectory(), "gcc\gcc.exe: " + Error$, #PB_MessageRequester_Ok | #PB_MessageRequester_Error)
      EndIf
      CloseProgram(Gcc)
    EndIf
    
    Output$ = "" : Error$ = ""
    Link = RunProgram(CompilerPath$ + "vc\link_real.exe", linkParam$, GetCurrentDirectory(), #PB_Program_Open | #PB_Program_Read | #PB_Program_Error )
    If Link
      While ProgramRunning(Link)
        If AvailableProgramOutput(Link)
          Output$ + ReadProgramString(Link) + #CRLF$
          Error$ + ReadProgramError(Link) + #CRLF$
        EndIf
      Wend
      If ProgramExitCode(Link) <> 0 
        Error$ + ReadProgramError(Link) + #CRLF$
        MessageRequester("Error " +  GetCurrentDirectory(), "vc\Link_real.exe: " + Error$, #PB_MessageRequester_Ok | #PB_MessageRequester_Error)
      EndIf
      CloseProgram(Link)
    EndIf
  CompilerEndIf
Else
  MessageRequester("Compilation Error", "Link_real.exe not found!", #PB_MessageRequester_Ok | #PB_MessageRequester_Error)
EndIf
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Re: Visual Studio linker download

Post by chi »

Glad I was able to help :P. Btw you should also change the other runtime libs from static to dynamic linking... Mixing the two makes little sense

Code: Select all

Import "ucrt.lib"      : EndImport  ;; libucrt.lib       The Universal CRT (UCRT) contains the functions and globals exported by the standard C99 CRT library.
Import "vcruntime.lib" : EndImport  ;; libvcruntime.lib  The vcruntime library contains Visual C++ CRT implementation-specific code: exception handling and debugging support, runtime checks and type information, implementation details, and certain extended library functions.
Import "msvcrt.lib"    : EndImport  ;; libcmt.lib        This code handles CRT startup, internal per-thread data initialization, and termination.      
Import "msvcprt.lib"   : EndImport  ;; libcpmt.lib       C++ standard library (STL) .lib files
Et cetera is my worst enemy
Post Reply