peixin added inline comments.

================
Comment at: flang/runtime/environment.cpp:77
+#else
+  envp = environ;
+#endif
----------------
What is `environ` used for? Should we try to keep as less extern variable as 
possible in runtime for security.


================
Comment at: flang/test/Driver/emit-mlir.f90:16
 ! CHECK-NEXT: }
+! CHECK-NEXT: fir.global @_QQEnvironmentDefaults constant : 
!fir.ref<tuple<i[[int_size:.*]], !fir.ref<!fir.array<0xtuple<!fir.ref<i8>, 
!fir.ref<i8>>>>>> {
+! CHECK-NEXT:  %[[VAL_0:.*]] = fir.zero_bits !fir.ref<tuple<i[[int_size]], 
!fir.ref<!fir.array<0xtuple<!fir.ref<i8>, !fir.ref<i8>>>>>>
----------------
jpenix-quic wrote:
> peixin wrote:
> > Is it possible not to generated this global variable if `fconvert=` is not 
> > specified?
> I'm not entirely sure--the issue I was running into was how to handle this in 
> Fortran_main.c in a way which worked for all of GCC/Clang/Visual Studio (and 
> maybe others?). I was originally thinking of doing this by using a weak 
> definition of _QQEnvironmentDefaults set to nullptr so fconvert, etc. could 
> override this definition without explicitly generating the fallback case. For 
> GCC/clang, I think I could use __attribute__((weak)), but I wasn't sure how 
> to handle this if someone tried to build with Visual Studio (or maybe another 
> toolchain). I saw a few workarounds (ex: 
> https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024) but I shied 
> away from this since it seems to be an undocumented feature (and presumably 
> only helps with Visual Studio). 
> 
> Do you know of a better or more general way I could do this? (Or, is there 
> non-weak symbol approach that might be better that I'm missing?)
How about generate one runtime function with the argument of 
`EnvironmentDefaultList`? This will avoid this and using one extern variable?

If users use one variable with bind C name `_QQEnvironmentDefaults` in fortran 
or one variable with name `_QQEnvironmentDefaults` in C, it is risky. Would 
using the runtime function and static variable with the type 
`EnvironmentDefaultList` in runtime be safer?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130513/new/

https://reviews.llvm.org/D130513

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to